Search in sources :

Example 6 with OutlineItem

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

the class OutlineItemTest method testContains.

public void testContains() {
    OutlineParser outlineParser = new OutlineParser(new TextileLanguage());
    OutlineItem outline = outlineParser.parse("h1. First Header\n\nh2. First Header First Child\n\nh1. Third Header\n");
    OutlineItem firstHeader = outline.getChildren().get(0);
    OutlineItem secondHeader = outline.getChildren().get(1);
    OutlineItem firstHeaderFirstChild = firstHeader.getChildren().get(0);
    assertTrue(outline.contains(firstHeader));
    assertTrue(outline.contains(secondHeader));
    assertTrue(firstHeader.contains(firstHeader));
    assertTrue(secondHeader.contains(secondHeader));
    assertFalse(firstHeader.contains(secondHeader));
    assertFalse(secondHeader.contains(firstHeader));
    assertFalse(firstHeaderFirstChild.contains(firstHeader));
    assertTrue(firstHeader.contains(firstHeaderFirstChild));
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) OutlineParser(org.eclipse.mylyn.wikitext.parser.outline.OutlineParser) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 7 with OutlineItem

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

the class XslfoDocumentBuilderIntegrationTest method testforTableCSSAttributes_bug336813.

public void testforTableCSSAttributes_bug336813() {
    final String markup = "{| style=\"border-style: solid; border-color: #000; border-width: 1px;\"\n" + "|-\n" + "! header 1\n" + "! header 2\n" + "! header 3\n" + "|-\n" + "| row 1, cell 1\n" + "| row 1, cell 2\n" + "| row 1, cell 3\n" + "|- style=\"border-style: solid; border-color: #000; border-width: 1px;\" \n" + "| row 2, cell 1\n" + "| row 2, cell 2\n" + "| style=\"border-style: solid; border-color: #000; border-width: 1px;\" | row 2, cell 3\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();
    // Test for border attributes in table
    assertTrue(Pattern.compile("<table-body border-color=\"#000\" border-style=\"solid\" border-width=\"1px\">").matcher(xslfo).find());
    // Test for border attributes in row
    assertTrue(Pattern.compile("<table-row border-color=\"#000\" border-style=\"solid\" border-width=\"1px\">").matcher(xslfo).find());
    // Test for border attributes in cell
    assertTrue(Pattern.compile("<block font-size=\"10.0pt\" border-color=\"#000\" border-style=\"solid\" border-width=\"1px\">").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 8 with OutlineItem

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

the class XslfoDocumentBuilderIntegrationTest method testforTableSpan_bug336813.

public void testforTableSpan_bug336813() {
    final String markup = "{|\n|-\n" + "| Column 1 || Column 2 || Column 3\n" + "|-\n" + "| rowspan=\"2\"| A\n" + "| colspan=\"2\" | B\n" + "|-\n" + "| C <!-- column 1 occupied by cell A -->\n" + "| D \n" + "|-\n" + "| E\n" + "| rowspan=\"2\" colspan=\"2\" | F\n" + "|- \n" + "| G <!-- column 2+3 occupied by cell F -->\n" + "|- \n" + "| colspan=\"3\" | H\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();
    // Test for rowspan
    assertTrue(Pattern.compile("<table-cell number-rows-spanned=\"2\" padding-left=\"2pt\" padding-right=\"2pt\" padding-top=\"2pt\" padding-bottom=\"2pt\">").matcher(xslfo).find());
    // Test for colspan
    assertTrue(Pattern.compile("<table-cell number-columns-spanned=\"2\" padding-left=\"2pt\" padding-right=\"2pt\" padding-top=\"2pt\" padding-bottom=\"2pt\">").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 9 with OutlineItem

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

the class XslfoDocumentBuilderIntegrationTest method testForXslFoBookmarks_bug336592.

public void testForXslFoBookmarks_bug336592() {
    final String markup = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n= Bookmark H1 =\n== Bookmark H2 ==\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();
    assertTrue(Pattern.compile("<bookmark-tree>\\s*<bookmark internal-destination=\"Bookmark_H1\">\\s*<bookmark-title>Bookmark H1</bookmark-title>\\s*<bookmark internal-destination=\"Bookmark_H2\">\\s*<bookmark-title>Bookmark H2</bookmark-title>\\s*</bookmark>\\s*</bookmark>\\s*</bookmark-tree>").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 10 with OutlineItem

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

the class WikiToDocTask method createToc.

private void createToc(final Path path, OutlineItem rootItem) {
    SplittingMarkupToEclipseToc markupToEclipseToc = new SplittingMarkupToEclipseToc() {

        @Override
        protected String computeFile(OutlineItem item) {
            if (item instanceof SplitOutlineItem) {
                return computeTocRelativeFile(item, path);
            }
            return super.computeFile(item);
        }
    };
    markupToEclipseToc.setBookTitle(path.getTitle());
    markupToEclipseToc.setHtmlFile(computeTocRelativeFile(rootItem, path));
    String tocContents = markupToEclipseToc.createToc(rootItem);
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
    File tocFile = new File(dest, path.name.replaceAll("[^a-zA-Z0-9]", "-") + "-toc.xml");
    try {
        // $NON-NLS-1$
        Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(tocFile)), "UTF-8");
        try {
            writer.write(tocContents);
        } finally {
            writer.close();
        }
    } catch (IOException e) {
        // $NON-NLS-1$
        String message = MessageFormat.format("Cannot write {0}: {1}", tocFile, e.getMessage());
        throw new BuildException(message, e);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) SplittingMarkupToEclipseToc(org.eclipse.mylyn.wikitext.splitter.SplittingMarkupToEclipseToc) SplitOutlineItem(org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) StringWriter(java.io.StringWriter) Writer(java.io.Writer) SplitOutlineItem(org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Aggregations

OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)58 OutlineParser (org.eclipse.mylyn.wikitext.parser.outline.OutlineParser)18 MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)9 Point (org.eclipse.swt.graphics.Point)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ITextSelection (org.eclipse.jface.text.ITextSelection)5 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)5 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)5 BufferedOutputStream (java.io.BufferedOutputStream)4 FileOutputStream (java.io.FileOutputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 Writer (java.io.Writer)4 BuildException (org.apache.tools.ant.BuildException)4 ISelection (org.eclipse.jface.viewers.ISelection)4 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)4 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 IMenuManager (org.eclipse.jface.action.IMenuManager)3 MenuManager (org.eclipse.jface.action.MenuManager)3