Search in sources :

Example 1 with TextileLanguage

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

the class HtmlTextPresentationParserTest method testSignificantWhitespaceLossBug236367.

/**
 * Test for bug# 236367
 */
@Test
public void testSignificantWhitespaceLossBug236367() throws SAXException, IOException {
    String html = new MarkupParser(new TextileLanguage()).parseToHtml("one *two* three *four* five *six* seven");
    parser.parse(html);
    String text = parser.getText();
    assertTrue(text.contains("one two three four five six seven"));
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 2 with TextileLanguage

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

the class OutlineItemTest method testGetSectionLength.

public void testGetSectionLength() {
    OutlineParser outlineParser = new OutlineParser(new TextileLanguage());
    String markup = "h1. First Header\n\nh2. First Header First Child\n\nh1. Third Header\n";
    OutlineItem outline = outlineParser.parse(markup);
    OutlineItem firstHeader = outline.getChildren().get(0);
    OutlineItem secondHeader = outline.getChildren().get(1);
    OutlineItem firstHeaderFirstChild = firstHeader.getChildren().get(0);
    assertEquals(markup.length(), outline.getSectionLength());
    assertEquals(48, firstHeader.getSectionLength());
    assertEquals(17, secondHeader.getSectionLength());
    assertEquals(30, firstHeaderFirstChild.getSectionLength());
}
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 3 with TextileLanguage

use of org.eclipse.mylyn.wikitext.textile.TextileLanguage 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 4 with TextileLanguage

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

the class HtmlDocumentBuilder2Test method setUp.

@Override
public void setUp() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    builder = new HtmlDocumentBuilder(out) {

        @Override
        protected void checkFileReadable(File file) {
            if (!fileToUrl.containsKey(file)) {
                super.checkFileReadable(file);
            }
        }

        @Override
        protected Reader getReader(File inputFile) throws FileNotFoundException {
            URL url = fileToUrl.get(inputFile);
            if (url != null) {
                try {
                    return new InputStreamReader(url.openStream());
                } catch (IOException e) {
                    throw new FileNotFoundException(String.format("%s (%s)", inputFile, url));
                }
            }
            return super.getReader(inputFile);
        }
    };
    parser.setBuilder(builder);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) InputStreamReader(java.io.InputStreamReader) FileNotFoundException(java.io.FileNotFoundException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) File(java.io.File) URL(java.net.URL) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 5 with TextileLanguage

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

the class XslfoDocumentBuilderIntegrationTest method testforXslFoLinks.

public void testforXslFoLinks() {
    final String markup = "\"INTERN-LABEL\":#intern_label\n" + "\"*INTERN-BOLD-LABEL*\":#intern_bold_label\n" + "\"EXTERN-LABEL\":http://extern-label.com/\n";
    documentBuilder.getConfiguration().setPageNumbering(false);
    documentBuilder.getConfiguration().setTitle("Title");
    parser.setMarkupLanguage(new TextileLanguage());
    parser.parse(markup);
    final String xslfo = out.toString();
    assertTrue(xslfo.contains("<basic-link internal-destination=\"intern_label\">INTERN-LABEL</basic-link>"));
    assertTrue(xslfo.contains("<basic-link internal-destination=\"intern_bold_label\"><inline font-weight=\"bold\">INTERN-BOLD-LABEL</inline></basic-link>"));
    assertTrue(xslfo.contains("<basic-link external-destination=\"url(http://extern-label.com/)\">EXTERN-LABEL</basic-link>"));
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage)

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