Search in sources :

Example 11 with TextileLanguage

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

the class MarkupTokenScannerTest method testTextileLinkWithStyle.

public void testTextileLinkWithStyle() {
    IDocument document = new Document();
    FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
    partitioner.setMarkupLanguage(new TextileLanguage());
    String markup = "\"_text_\":http://example.com";
    document.set(markup);
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    partitioner.computePartitioning(0, document.getLength(), false);
    tokenScanner.setRange(document, 0, document.getLength());
    List<MarkupTokenScanner.Token> tokens = new ArrayList<MarkupTokenScanner.Token>();
    for (IToken token = tokenScanner.nextToken(); token != Token.EOF; token = tokenScanner.nextToken()) {
        tokens.add((MarkupTokenScanner.Token) token);
    }
    // expecting:
    // Token [offset=0, length=1]
    // Token [offset=1, length=6]
    // Token [offset=7, length=20]
    assertEquals(3, tokens.size());
    assertEquals(0, tokens.get(0).getOffset());
    assertEquals(1, tokens.get(0).getLength());
    assertFalse(tokens.get(0).getFontState().isItalic());
    assertEquals(1, tokens.get(1).getOffset());
    assertEquals(6, tokens.get(1).getLength());
    assertTrue(tokens.get(1).getFontState().isItalic());
    assertEquals(7, tokens.get(2).getOffset());
    assertEquals(20, tokens.get(2).getLength());
    assertFalse(tokens.get(2).getFontState().isItalic());
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) IToken(org.eclipse.jface.text.rules.IToken) ArrayList(java.util.ArrayList) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument)

Example 12 with TextileLanguage

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

the class MarkupToEclipseTocTest method setUp.

@Override
public void setUp() {
    markupToEclipseToc = new MarkupToEclipseToc();
    markupToEclipseToc.setMarkupLanguage(new TextileLanguage());
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) MarkupToEclipseToc(org.eclipse.mylyn.wikitext.parser.util.MarkupToEclipseToc)

Example 13 with TextileLanguage

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

the class FastMarkupPartitionerTest method testConnectLargeDocument.

public void testConnectLargeDocument() throws IOException {
    IDocument document = createDocument("resources/large.textile");
    FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
    partitioner.setMarkupLanguage(new TextileLanguage());
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) IDocument(org.eclipse.jface.text.IDocument)

Example 14 with TextileLanguage

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

the class FastMarkupPartitionerTest method testTextileCausesExceptionIssue36.

public void testTextileCausesExceptionIssue36() {
    IDocument document = new Document();
    FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
    partitioner.setMarkupLanguage(new TextileLanguage());
    document.set("a\n" + "# a\n" + "a\n" + "# a\n" + "a\n" + "# a\n" + "\n" + "h2. a");
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument)

Example 15 with TextileLanguage

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

the class FastMarkupPartitionerTest method testTextileLinkInBold.

/**
 * bug 314131
 */
public void testTextileLinkInBold() {
    IDocument document = new Document();
    FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
    partitioner.setMarkupLanguage(new TextileLanguage());
    document.set("*\"text\":url*");
    // ...........012345678901.234567.8.9012345678901.234567.
    // .....................10...........20.........30.......
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    int[][] expected = new int[][] { // 
    { 0, 12 } };
    ITypedRegion[] partitioning = partitioner.computePartitioning(0, document.getLength(), false);
    assertPartitioningAsExpected(expected, partitioning);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) ITypedRegion(org.eclipse.jface.text.ITypedRegion) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument)

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