Search in sources :

Example 6 with EventDocumentBuilder

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

the class CompositeSpanStrategyTest method test.

@Test
public void test() {
    CompositeSpanStrategy strategy = new CompositeSpanStrategy(Lists.<SpanStrategy>newArrayList(new SubstitutionWithoutCssSpanStrategy(SpanType.BOLD), new SubstitutionWithoutCssSpanStrategy(SpanType.ITALIC)));
    EventDocumentBuilder builder = new EventDocumentBuilder();
    strategy.beginSpan(builder, SpanType.DELETED, new Attributes());
    strategy.endSpan(builder);
    DocumentBuilderEvents events = builder.getDocumentBuilderEvents();
    assertEquals(ImmutableList.of(new BeginSpanEvent(SpanType.BOLD, new Attributes()), new BeginSpanEvent(SpanType.ITALIC, new Attributes()), new EndSpanEvent(), new EndSpanEvent()), events.getEvents());
}
Also used : DocumentBuilderEvents(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvents) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) CompositeSpanStrategy(org.eclipse.mylyn.wikitext.html.internal.CompositeSpanStrategy) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BeginSpanEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginSpanEvent) EndSpanEvent(org.eclipse.mylyn.wikitext.parser.builder.event.EndSpanEvent) SubstitutionWithoutCssSpanStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionWithoutCssSpanStrategy) Test(org.junit.Test)

Example 7 with EventDocumentBuilder

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

the class EventDocumentBuilderTest method assertEvents.

private void assertEvents(DocumentBuilderEvent... events) {
    List<DocumentBuilderEvent> expectedEvents = Arrays.asList(events);
    assertEquals(expectedEvents, builder.getDocumentBuilderEvents().getEvents());
    EventDocumentBuilder builder2 = new EventDocumentBuilder();
    for (DocumentBuilderEvent event : events) {
        event.invoke(builder2);
    }
    assertEquals(expectedEvents, builder2.getDocumentBuilderEvents().getEvents());
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)

Example 8 with EventDocumentBuilder

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

the class FontElementStrategyTest method spanStrategyBuildsNonHtml.

@Test
public void spanStrategyBuildsNonHtml() {
    EventDocumentBuilder builder = new EventDocumentBuilder();
    SpanStrategy spanStrategy = strategy.spanStrategy();
    spanStrategy.beginSpan(builder, SpanType.SPAN, new Attributes(null, null, "color: red", null));
    builder.characters("test");
    spanStrategy.endSpan(builder);
    assertEquals(Arrays.asList(new BeginSpanEvent(SpanType.SPAN, new Attributes(null, null, "color: red", null)), new CharactersEvent("test"), new EndSpanEvent()), builder.getDocumentBuilderEvents().getEvents());
}
Also used : SpanStrategy(org.eclipse.mylyn.wikitext.html.internal.SpanStrategy) CharactersEvent(org.eclipse.mylyn.wikitext.parser.builder.event.CharactersEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BeginSpanEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginSpanEvent) EndSpanEvent(org.eclipse.mylyn.wikitext.parser.builder.event.EndSpanEvent) Test(org.junit.Test)

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