Search in sources :

Example 36 with MarkupParser

use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.

the class CommonMarkLanguageTest method assertEvents.

private void assertEvents(String content, boolean asDocument, DocumentBuilderEvent... events) {
    MarkupParser parser = new MarkupParser(language);
    EventDocumentBuilder builder = new EventDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse(content, asDocument);
    List<DocumentBuilderEvent> expectedEvents = Arrays.asList(events);
    List<DocumentBuilderEvent> actualEvents = builder.getDocumentBuilderEvents().getEvents();
    assertEquals(format("Expected {0} but got {1}", toMessage(expectedEvents), toMessage(actualEvents)), expectedEvents, actualEvents);
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 37 with MarkupParser

use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.

the class AsciiDocLanguageWithConfigurationIntegrationTest method parseWithImagesdirConfiguration.

@Test
public void parseWithImagesdirConfiguration() {
    AsciiDocMarkupLanguageConfiguration configuration = new AsciiDocMarkupLanguageConfiguration();
    Map<String, String> initialAttributes = new HashMap<>();
    initialAttributes.put("imagesdir", "IMGS");
    configuration.setInitialAttributes(initialAttributes);
    MarkupParser parser = createParserWithConfiguration(configuration);
    String markup = "See this the {imagesdir} folder";
    String html = parseAsciiDocToHtml(markup, parser);
    assertEquals("<p>See this the IMGS folder</p>\n", html);
}
Also used : AsciiDocMarkupLanguageConfiguration(org.eclipse.mylyn.wikitext.asciidoc.AsciiDocMarkupLanguageConfiguration) HashMap(java.util.HashMap) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 38 with MarkupParser

use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.

the class AsciiDocLanguageWithConfigurationIntegrationTest method parseWithEmptyConfiguration.

@Test
public void parseWithEmptyConfiguration() {
    AsciiDocMarkupLanguageConfiguration configuration = new AsciiDocMarkupLanguageConfiguration();
    MarkupParser parser = createParserWithConfiguration(configuration);
    String html = parseAsciiDocToHtml(AsciiDocLanguageAttributeTest.MARKUP_FOR_DEFAULT, parser);
    AsciiDocLanguageAttributeTest.ensureDefaultValues(html);
}
Also used : AsciiDocMarkupLanguageConfiguration(org.eclipse.mylyn.wikitext.asciidoc.AsciiDocMarkupLanguageConfiguration) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 39 with MarkupParser

use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.

the class HtmlLanguageIntegrationTest method emitImageWithoutImageSupport.

@Test
public void emitImageWithoutImageSupport() {
    MarkupLanguage sourceLanguage = getDefaultMarkupLanguage("Source HTML");
    MarkupLanguage targetLanguageWithNoImageSupport = getMarkupLanguageWithoutImageSupport("Target HTML With No Images");
    StringWriter stringWriter = new StringWriter();
    MarkupParser markupParser = getMarkupParser(sourceLanguage, targetLanguageWithNoImageSupport, stringWriter);
    markupParser.parse("Text Before Image<img src=\"/favicon.ico\"/>Text After Image", false);
    assertEquals("Text Before ImageText After Image", stringWriter.toString());
}
Also used : StringWriter(java.io.StringWriter) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 40 with MarkupParser

use of org.eclipse.mylyn.wikitext.parser.MarkupParser in project mylyn.docs by eclipse.

the class MarkdownLanguageParagraphBreakingBlocksDisabledTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    parser = new MarkupParser(new Language());
}
Also used : MarkdownLanguage(org.eclipse.mylyn.wikitext.markdown.MarkdownLanguage) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Aggregations

MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)55 StringWriter (java.io.StringWriter)24 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)17 Writer (java.io.Writer)13 Test (org.junit.Test)10 File (java.io.File)8 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)8 TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)8 OutputStreamWriter (java.io.OutputStreamWriter)7 FileOutputStream (java.io.FileOutputStream)6 BufferedOutputStream (java.io.BufferedOutputStream)5 IOException (java.io.IOException)5 BuildException (org.apache.tools.ant.BuildException)5 IFile (org.eclipse.core.resources.IFile)4 EventDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)4 PrintWriter (java.io.PrintWriter)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HtmlLanguage (org.eclipse.mylyn.wikitext.html.HtmlLanguage)3 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)3