Search in sources :

Example 6 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class TextileLanguageTest method testLinkWithItalicStyle.

@Test
public void testLinkWithItalicStyle() {
    RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse("\"_text_\":http://example.com");
    List<Event> events = builder.getEvents();
    boolean emphasisFound = false;
    boolean textFound = false;
    for (Event event : events) {
        if (event.spanType == SpanType.EMPHASIS) {
            assertEquals(1, event.locator.getLineCharacterOffset());
            assertEquals(7, event.locator.getLineSegmentEndOffset());
            emphasisFound = true;
        } else if (event.text != null) {
            assertEquals(2, event.locator.getLineCharacterOffset());
            assertEquals(6, event.locator.getLineSegmentEndOffset());
            textFound = true;
        }
    }
    assertTrue("expected to find emphasis span", emphasisFound);
    assertTrue("expected to find text", textFound);
}
Also used : Event(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder.Event) RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 7 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class TextileLanguageDefinitionListTest method offsets.

@Test
public void offsets() {
    RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    MarkupParser markupParser = new MarkupParser(markupLanguage);
    markupParser.setBuilder(builder);
    markupParser.parse("- one := two");
    Event event = findEvent(builder.getEvents(), BlockType.DEFINITION_TERM);
    assertEquals(1, event.locator.getLineNumber());
    assertEquals(0, event.locator.getLineCharacterOffset());
    assertEquals(6, event.locator.getLineSegmentEndOffset());
    Event itemEvent = findEvent(builder.getEvents(), BlockType.DEFINITION_ITEM);
    assertEquals(1, itemEvent.locator.getLineNumber());
    assertEquals(6, itemEvent.locator.getLineCharacterOffset());
}
Also used : Event(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder.Event) RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 8 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class AsciiDocLanguageTestBase method parseToEvents.

public List<Event> parseToEvents(String markup) {
    RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse(markup);
    return builder.getEvents();
}
Also used : RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder)

Example 9 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class ConfluenceLanguageTest method testColorLexicalOffsets.

@Test
public void testColorLexicalOffsets() {
    final RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    final String content = "views to help SOA  development. These includes [SOA Services Explorer](in green) for the list of all available SOA services,\n[Types Explorer](in {color:#0000ff}blue{color}) for searching and browsing all available ";
    parser.parse(content);
    int previousDocumentOffset = -1;
    for (RecordingDocumentBuilder.Event event : builder.getEvents()) {
        assertTrue(previousDocumentOffset <= event.locator.getDocumentOffset());
        previousDocumentOffset = event.locator.getDocumentOffset();
        if (event.text != null) {
            int start = event.locator.getDocumentOffset();
            int end = event.locator.getLineSegmentEndOffset() + event.locator.getLineDocumentOffset();
            assertEquals(event.text.length(), end - start);
            assertTrue(end >= start);
            assertEquals(content.substring(start, end), event.text);
        }
    }
}
Also used : RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 10 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class MarkdownLanguageTestBase method parseToEvents.

protected List<Event> parseToEvents(String markupContent) {
    RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse(markupContent);
    return builder.getEvents();
}
Also used : RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder)

Aggregations

RecordingDocumentBuilder (org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder)11 Test (org.junit.Test)9 AbstractMarkupGenerationTest (org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)8 Event (org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder.Event)4 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1