Search in sources :

Example 16 with TextileLanguage

use of org.eclipse.mylyn.wikitext.textile.TextileLanguage in project mylyn.docs by eclipse.

the class DitaTopicDocumentBuilderTest method testNoFormatting.

public void testNoFormatting() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    DefaultXmlStreamWriter xmlStreamWriter = new DefaultXmlStreamWriter(out);
    builder = new DitaTopicDocumentBuilder(xmlStreamWriter, false);
    parser.setBuilder(builder);
    parser.parse("h1. Title1\n\nsome content in a para");
    xmlStreamWriter.close();
    String dita = out.toString();
    assertTrue(dita.contains("<topic id=\"Title1\"><title>Title1</title><body><p>some content in a para</p></body></topic>"));
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) DitaTopicDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.DitaTopicDocumentBuilder) DefaultXmlStreamWriter(org.eclipse.mylyn.wikitext.util.DefaultXmlStreamWriter) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 17 with TextileLanguage

use of org.eclipse.mylyn.wikitext.textile.TextileLanguage in project mylyn.docs by eclipse.

the class DitaTopicDocumentBuilderTest method setUp.

@Override
public void setUp() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    builder = new DitaTopicDocumentBuilder(out);
    parser.setBuilder(builder);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) DitaTopicDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.DitaTopicDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 18 with TextileLanguage

use of org.eclipse.mylyn.wikitext.textile.TextileLanguage in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderIntegrationTest method setUp.

@Override
public void setUp() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    builder = new DocBookDocumentBuilder(out);
    parser.setBuilder(builder);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 19 with TextileLanguage

use of org.eclipse.mylyn.wikitext.textile.TextileLanguage in project mylyn.docs by eclipse.

the class ParagraphBlock method processLineContent.

@Override
public int processLineContent(String line, int offset) {
    if (blockLineCount == 0) {
        Attributes attributes = new Attributes();
        if (offset == 0) {
            // 0-offset matches may start with the "p. " prefix.
            Matcher matcher = startPattern.matcher(line);
            if (matcher.matches()) {
                Textile.configureAttributes(attributes, matcher, 1, true);
                offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
            } else {
                if (line.charAt(0) == ' ') {
                    offset = 1;
                    if (enableUnwrapped) {
                        unwrapped = true;
                    }
                }
            }
        }
        if (!unwrapped) {
            builder.beginBlock(BlockType.PARAGRAPH, attributes);
        }
    }
    if (markupLanguage.isEmptyLine(line)) {
        setClosed(true);
        return 0;
    }
    TextileLanguage textileLanguage = (TextileLanguage) getMarkupLanguage();
    // however we cause them to end the paragraph rather than being nested.
    for (Block block : textileLanguage.getParagraphBreakingBlocks()) {
        if (block.canStart(line, offset)) {
            setClosed(true);
            return offset;
        }
    }
    if (blockLineCount != 0) {
        if (unwrapped) {
            // $NON-NLS-1$
            builder.characters("\n");
        } else {
            builder.lineBreak();
        }
    }
    ++blockLineCount;
    textileLanguage.emitMarkupLine(getParser(), state, line, offset);
    return -1;
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) Matcher(java.util.regex.Matcher) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Example 20 with TextileLanguage

use of org.eclipse.mylyn.wikitext.textile.TextileLanguage in project mylyn.docs by eclipse.

the class AbstractSaxParserTest method performTest.

protected void performTest(String html, String expectedResult) throws IOException, SAXException {
    parser.parse(sourceForHtml(html), builder, true);
    String generatedMarkup = out.toString();
    assertEquals(expectedResult, generatedMarkup);
    MarkupParser markupParser = new MarkupParser(new TextileLanguage());
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder htmlBuilder = new HtmlDocumentBuilder(out);
    htmlBuilder.setEmitAsDocument(false);
    markupParser.setBuilder(htmlBuilder);
    markupParser.parse(generatedMarkup);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Aggregations

TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)22 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)8 StringWriter (java.io.StringWriter)6 IDocument (org.eclipse.jface.text.IDocument)6 Document (org.eclipse.jface.text.Document)5 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)4 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)3 OutlineParser (org.eclipse.mylyn.wikitext.parser.outline.OutlineParser)3 ITypedRegion (org.eclipse.jface.text.ITypedRegion)2 DitaTopicDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.DitaTopicDocumentBuilder)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Reader (java.io.Reader)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1