예제 #1
0
 @Test
 public void testEm() throws Exception {
   XdocFactory fac = XdocFactory.eINSTANCE;
   Emphasize emphasize = fac.createEmphasize();
   TextOrMarkup textOrMarkup = fac.createTextOrMarkup();
   TextPart textPart = fac.createTextPart();
   textPart.setText("Testtext_");
   textOrMarkup.getContents().add(textPart);
   emphasize.getContents().add(textOrMarkup);
   String expected = "<em>Testtext_</em>";
   String actual = generator.genText(emphasize).toString();
   assertEquals(expected, actual);
   // and for two paragraphs in one em
   TextOrMarkup textOrMarkup2 = fac.createTextOrMarkup();
   TextPart textPart2 = fac.createTextPart();
   textPart2.setText("more test");
   textOrMarkup2.getContents().add(textPart2);
   emphasize.getContents().add(textOrMarkup2);
   expected =
       "<em>\n"
           + "<p>\n"
           + "Testtext_\n"
           + "</p>\n"
           + "<p>\n"
           + "more test\n"
           + "</p>\n"
           + "</em>";
   actual = generator.genText(emphasize).toString();
   assertEquals(expected, actual);
 }
예제 #2
0
 public Section getSection(String title) {
   Section section = XdocFactory.eINSTANCE.createSection();
   TextPart tp = XdocFactory.eINSTANCE.createTextPart();
   tp.setText(title);
   TextOrMarkup tom = XdocFactory.eINSTANCE.createTextOrMarkup();
   tom.getContents().add(tp);
   section.setTitle(tom);
   return section;
 }
예제 #3
0
 public Chapter getChapter(String title) {
   Chapter chapter = XdocFactory.eINSTANCE.createChapter();
   TextPart tp = XdocFactory.eINSTANCE.createTextPart();
   tp.setText(title);
   TextOrMarkup tom = XdocFactory.eINSTANCE.createTextOrMarkup();
   tom.getContents().add(tp);
   chapter.setTitle(tom);
   return chapter;
 }
예제 #4
0
 protected CharSequence _toHtml(final TextOrMarkup it) {
   EList<EObject> _contents = it.getContents();
   CharSequence _html = this.toHtml(_contents);
   return _html;
 }
예제 #5
0
 protected CharSequence internalToHtmlParagraph(final Object it) {
   CharSequence _switchResult = null;
   boolean matched = false;
   if (!matched) {
     if (it instanceof TextOrMarkup) {
       final TextOrMarkup _textOrMarkup = (TextOrMarkup) it;
       matched = true;
       EList<EObject> _contents = _textOrMarkup.getContents();
       CharSequence _internalToHtmlParagraph = this.internalToHtmlParagraph(_contents);
       _switchResult = _internalToHtmlParagraph;
     }
   }
   if (!matched) {
     if (it instanceof List) {
       final List<EObject> _list = (List<EObject>) it;
       matched = true;
       final Function1<EObject, CharSequence> _function =
           new Function1<EObject, CharSequence>() {
             public CharSequence apply(final EObject it) {
               CharSequence _internalToHtmlParagraph =
                   HtmlExtensions.this.internalToHtmlParagraph(it);
               return _internalToHtmlParagraph;
             }
           };
       List<CharSequence> _map = ListExtensions.<EObject, CharSequence>map(_list, _function);
       String _join = IterableExtensions.join(_map);
       _switchResult = _join;
     }
   }
   if (!matched) {
     if (it instanceof TextPart) {
       final TextPart _textPart = (TextPart) it;
       matched = true;
       String _xblockexpression = null;
       {
         String _text = _textPart.getText();
         String _quote = this.quote(_text);
         String[] _split = _quote.split("^\\s*$");
         final String[] paragraphs = _split;
         final String[] _typeConverted_paragraphs = (String[]) paragraphs;
         final Function1<String, Boolean> _function =
             new Function1<String, Boolean>() {
               public Boolean apply(final String it) {
                 boolean _isEmpty = it.isEmpty();
                 boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
                 return Boolean.valueOf(_operator_not);
               }
             };
         Iterable<String> _filter =
             IterableExtensions.<String>filter(
                 ((Iterable<String>) Conversions.doWrapArray(_typeConverted_paragraphs)),
                 _function);
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("</p>");
         _builder.newLine();
         _builder.append("<p>");
         _builder.newLine();
         String _join = IterableExtensions.join(_filter, _builder);
         _xblockexpression = (_join);
       }
       _switchResult = _xblockexpression;
     }
   }
   if (!matched) {
     if (it instanceof CodeBlock) {
       final CodeBlock _codeBlock = (CodeBlock) it;
       matched = true;
       CharSequence _internalToHtml = this.internalToHtml(_codeBlock, true);
       _switchResult = _internalToHtml;
     }
   }
   if (!matched) {
     CharSequence _html = this.toHtml(it);
     _switchResult = _html;
   }
   return _switchResult;
 }