Search in sources :

Example 11 with MediaWikiLanguage

use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testComputeOutline.

@Test
public void testComputeOutline() throws IOException {
    OutlineParser outlineParser = new OutlineParser();
    outlineParser.setMarkupLanguage(new MediaWikiLanguage());
    OutlineItem outline = outlineParser.parse(readFully("sample.mediawiki"));
    Set<String> topLevelLabels = new LinkedHashSet<String>();
    Set<String> topLevelIds = new LinkedHashSet<String>();
    List<OutlineItem> children = outline.getChildren();
    for (OutlineItem item : children) {
        topLevelLabels.add(item.getLabel());
        topLevelIds.add(item.getId());
    }
    assertEquals(children.size(), topLevelIds.size());
    assertEquals(children.size(), topLevelLabels.size());
    assertTrue("Top-level labels: " + topLevelLabels, topLevelLabels.contains("Task-Focused UI"));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OutlineParser(org.eclipse.mylyn.wikitext.parser.outline.OutlineParser) MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 12 with MediaWikiLanguage

use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testCloneTemplateExcludes.

@Test
public void testCloneTemplateExcludes() {
    markupLanguage.setTemplateExcludes("*foo");
    MediaWikiLanguage copy = (MediaWikiLanguage) markupLanguage.clone();
    assertEquals(markupLanguage.getTemplateExcludes(), copy.getTemplateExcludes());
}
Also used : MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 13 with MediaWikiLanguage

use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testDiscoverable.

@Test
public void testDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("MediaWiki");
    assertNotNull(language);
    assertTrue(language instanceof MediaWikiLanguage);
}
Also used : MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 14 with MediaWikiLanguage

use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.

the class XslfoDocumentBuilderIntegrationTest method testforTableCellTextAlign_bug336813.

public void testforTableCellTextAlign_bug336813() {
    final String markup = "{|\n" + "|- \n |'''Row heading'''\n" + "| align=\"left\" | A longer piece of text. Lorem ipsum...\n |A shorter piece of text.\n" + "|- \n |'''Row heading'''\n" + "| style=\"text-align: right;\" | A longer piece of text. Lorem ipsum... \n |A shorter piece of text.\n" + "|}";
    documentBuilder.getConfiguration().setPageNumbering(true);
    documentBuilder.getConfiguration().setTitle("Title");
    OutlineItem op = new OutlineParser(new MediaWikiLanguage()).parse(markup);
    documentBuilder.setOutline(op);
    parser.setMarkupLanguage(new MediaWikiLanguage());
    parser.parse(markup, true);
    final String xslfo = out.toString();
    // From "text-align" attribute
    assertTrue(Pattern.compile("<table-cell text-align=\"left\"").matcher(xslfo).find());
    // From css styling
    assertTrue(Pattern.compile("<block font-size=\"10.0pt\" text-align=\"right\">").matcher(xslfo).find());
}
Also used : OutlineParser(org.eclipse.mylyn.wikitext.parser.outline.OutlineParser) MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 15 with MediaWikiLanguage

use of org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage in project mylyn.docs by eclipse.

the class XslfoDocumentBuilderIntegrationTest method testforTableCellAlign_bug336813.

public void testforTableCellAlign_bug336813() {
    final String markup = "{|\n" + "|- \n |'''Row heading'''\n" + "| valign=\"top\" | A longer piece of text. Lorem ipsum...\n |A shorter piece of text.\n" + "|- \n |'''Row heading'''\n" + "| style=\"vertical-align: bottom;\" | A longer piece of text. Lorem ipsum... \n |A shorter piece of text.\n" + "|}";
    documentBuilder.getConfiguration().setPageNumbering(true);
    documentBuilder.getConfiguration().setTitle("Title");
    OutlineItem op = new OutlineParser(new MediaWikiLanguage()).parse(markup);
    documentBuilder.setOutline(op);
    parser.setMarkupLanguage(new MediaWikiLanguage());
    parser.parse(markup, true);
    final String xslfo = out.toString();
    // From "valign" attribute
    assertTrue(Pattern.compile("<table-cell display-align=\"before\"").matcher(xslfo).find());
    // From css styling
    assertTrue(Pattern.compile("<block font-size=\"10.0pt\" display-align=\"after\">").matcher(xslfo).find());
}
Also used : OutlineParser(org.eclipse.mylyn.wikitext.parser.outline.OutlineParser) MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Aggregations

MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)17 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)9 OutlineParser (org.eclipse.mylyn.wikitext.parser.outline.OutlineParser)9 AbstractMarkupGenerationTest (org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)3 Test (org.junit.Test)3 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 BuildException (org.apache.tools.ant.BuildException)2 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)2 SplitOutlineItem (org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Reader (java.io.Reader)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1