Search in sources :

Example 16 with OutlineParser

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineParser 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 17 with OutlineParser

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineParser 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)

Example 18 with OutlineParser

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

the class TableOfContentsBlock method processLineContent.

@Override
public int processLineContent(String line, int offset) {
    if (blockLineNumber++ > 0) {
        setClosed(true);
        return 0;
    }
    if (!getMarkupLanguage().isFilterGenerativeContents()) {
        OutlineParser outlineParser = new OutlineParser(new MediaWikiLanguage());
        OutlineItem rootItem = outlineParser.parse(state.getMarkupContent());
        emitToc(rootItem);
    }
    int start = matcher.start(1);
    if (start > 0) {
        setClosed(true);
    }
    return start;
}
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 19 with OutlineParser

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

the class TableOfContentsBlock method processLineContent.

@Override
public int processLineContent(String line, int offset) {
    if (blockLineNumber++ > 0) {
        setClosed(true);
        return 0;
    }
    if (!getMarkupLanguage().isFilterGenerativeContents()) {
        String options = matcher.group(1);
        if (options != null) {
            // $NON-NLS-1$
            String[] optionPairs = options.split("\\s*\\|\\s*");
            for (String optionPair : optionPairs) {
                // $NON-NLS-1$
                String[] keyValue = optionPair.split("\\s*=\\s*");
                if (keyValue.length == 2) {
                    String key = keyValue[0].trim();
                    String value = keyValue[1].trim();
                    if (key.equals(OPTION_STYLE)) {
                        setStyle(value);
                    } else if (key.equals(OPTION_MAX_LEVEL)) {
                        try {
                            maxLevel = Integer.parseInt(value);
                        } catch (NumberFormatException e) {
                        }
                    } else if (key.equals(OPTION_CLASS)) {
                        setCssClass(value);
                    }
                }
            }
        }
        OutlineParser outlineParser = new OutlineParser(new TextileLanguage());
        OutlineItem rootItem = outlineParser.parse(state.getMarkupContent());
        emitToc(rootItem);
    }
    return -1;
}
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)

Aggregations

OutlineParser (org.eclipse.mylyn.wikitext.parser.outline.OutlineParser)19 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)18 MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)9 TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)3 BufferedOutputStream (java.io.BufferedOutputStream)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Writer (java.io.Writer)2 BuildException (org.apache.tools.ant.BuildException)2 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)2 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 ConfluenceLanguage (org.eclipse.mylyn.wikitext.confluence.ConfluenceLanguage)1 DitaBookMapDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.DitaBookMapDocumentBuilder)1 DitaTopicDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.DitaTopicDocumentBuilder)1 XslfoDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.XslfoDocumentBuilder)1 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)1 AbstractMarkupGenerationTest (org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)1