Search in sources :

Example 1 with EventDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder in project mylyn.docs by eclipse.

the class MultiplexingDocumentBuilderTest method newDelegateAfterInstatiation.

@Test
public void newDelegateAfterInstatiation() {
    multiplexer.lineBreak();
    assertEvents(new LineBreakEvent());
    EventDocumentBuilder delegate3 = new EventDocumentBuilder();
    multiplexer.addDocumentBuilder(delegate3);
    multiplexer.acronym("a", "b");
    assertEvents(new LineBreakEvent(), new AcronymEvent("a", "b"));
    assertEquals(Arrays.asList(new AcronymEvent("a", "b")), delegate3.getDocumentBuilderEvents().getEvents());
}
Also used : AcronymEvent(org.eclipse.mylyn.wikitext.parser.builder.event.AcronymEvent) LineBreakEvent(org.eclipse.mylyn.wikitext.parser.builder.event.LineBreakEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) Test(org.junit.Test)

Example 2 with EventDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder in project mylyn.docs by eclipse.

the class SubstitutionWithoutCssSpanStrategyTest method test.

@Test
public void test() {
    SubstitutionWithoutCssSpanStrategy strategy = new SubstitutionWithoutCssSpanStrategy(SpanType.BOLD);
    EventDocumentBuilder builder = new EventDocumentBuilder();
    strategy.beginSpan(builder, SpanType.ITALIC, new Attributes("1", "class", "style", "lang"));
    List<DocumentBuilderEvent> events = builder.getDocumentBuilderEvents().getEvents();
    assertEquals(ImmutableList.of(new BeginSpanEvent(SpanType.BOLD, new Attributes("1", "class", null, "lang"))), events);
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BeginSpanEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginSpanEvent) SubstitutionWithoutCssSpanStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionWithoutCssSpanStrategy) Test(org.junit.Test)

Example 3 with EventDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder in project mylyn.docs by eclipse.

the class ConfluenceLanguageIntegrationTest method parseToEvents.

private DocumentBuilderEvents parseToEvents(String markup) {
    EventDocumentBuilder eventBuilder = new EventDocumentBuilder();
    MarkupParser parser = new MarkupParser(new ConfluenceLanguage(), eventBuilder);
    parser.parse(markup);
    DocumentBuilderEvents events = eventBuilder.getDocumentBuilderEvents();
    return events;
}
Also used : DocumentBuilderEvents(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvents) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 4 with EventDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder in project mylyn.docs by eclipse.

the class SourceBlocksTest method process.

@Test
public void process() {
    EventDocumentBuilder builder = new EventDocumentBuilder();
    sourceBlocks.process(ProcessingContext.builder().build(), builder, LineSequence.create("one\nb2\nmore\n\nb1 and\n\n\nb2"));
    ImmutableList<DocumentBuilderEvent> expectedEvents = // 
    ImmutableList.of(// 
    new BeginBlockEvent(BlockType.PARAGRAPH, new Attributes()), // 
    new CharactersEvent("b2"), // 
    new CharactersEvent("more"), // 
    new EndBlockEvent(), // 
    new BeginBlockEvent(BlockType.QUOTE, new Attributes()), // 
    new CharactersEvent("b1 and"), // 
    new EndBlockEvent(), // 
    new BeginBlockEvent(BlockType.PARAGRAPH, new Attributes()), // 
    new CharactersEvent("b2"), new EndBlockEvent());
    assertEquals(Joiner.on("\n").join(builder.getDocumentBuilderEvents().getEvents()), expectedEvents, builder.getDocumentBuilderEvents().getEvents());
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) CharactersEvent(org.eclipse.mylyn.wikitext.parser.builder.event.CharactersEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) EndBlockEvent(org.eclipse.mylyn.wikitext.parser.builder.event.EndBlockEvent) BeginBlockEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginBlockEvent) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Test(org.junit.Test)

Example 5 with EventDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder in project mylyn.docs by eclipse.

the class CommonMarkLanguageTest method assertEvents.

private void assertEvents(String content, boolean asDocument, DocumentBuilderEvent... events) {
    MarkupParser parser = new MarkupParser(language);
    EventDocumentBuilder builder = new EventDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse(content, asDocument);
    List<DocumentBuilderEvent> expectedEvents = Arrays.asList(events);
    List<DocumentBuilderEvent> actualEvents = builder.getDocumentBuilderEvents().getEvents();
    assertEquals(format("Expected {0} but got {1}", toMessage(expectedEvents), toMessage(actualEvents)), expectedEvents, actualEvents);
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Aggregations

EventDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)8 Test (org.junit.Test)5 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)4 DocumentBuilderEvent (org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent)4 BeginSpanEvent (org.eclipse.mylyn.wikitext.parser.builder.event.BeginSpanEvent)3 SubstitutionWithoutCssSpanStrategy (org.eclipse.mylyn.wikitext.html.internal.SubstitutionWithoutCssSpanStrategy)2 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)2 CharactersEvent (org.eclipse.mylyn.wikitext.parser.builder.event.CharactersEvent)2 DocumentBuilderEvents (org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvents)2 EndSpanEvent (org.eclipse.mylyn.wikitext.parser.builder.event.EndSpanEvent)2 CompositeSpanStrategy (org.eclipse.mylyn.wikitext.html.internal.CompositeSpanStrategy)1 SpanStrategy (org.eclipse.mylyn.wikitext.html.internal.SpanStrategy)1 AcronymEvent (org.eclipse.mylyn.wikitext.parser.builder.event.AcronymEvent)1 BeginBlockEvent (org.eclipse.mylyn.wikitext.parser.builder.event.BeginBlockEvent)1 EndBlockEvent (org.eclipse.mylyn.wikitext.parser.builder.event.EndBlockEvent)1 LineBreakEvent (org.eclipse.mylyn.wikitext.parser.builder.event.LineBreakEvent)1