use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType in project mylyn.docs by eclipse.
the class CssClassPhraseModifier method newProcessor.
@Override
protected PatternBasedElementProcessor newProcessor() {
return new PatternBasedElementProcessor() {
@Override
public void emit() {
Attributes attributes = new Attributes();
SpanType span = SpanType.SPAN;
String cssClass = group(1);
if (cssClass != null && !cssClass.isEmpty()) {
attributes.setCssClass(cssClass);
} else {
span = SpanType.MARK;
}
getBuilder().beginSpan(span, attributes);
getBuilder().characters(group(2));
getBuilder().endSpan();
}
};
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType in project mylyn.docs by eclipse.
the class HtmlParserTest method assertParseEventOrder.
private void assertParseEventOrder(String content, Object... expectedEventTypes) {
final List<Object> actualEventTypes = new ArrayList<>();
DocumentBuilder builder = new NoOpDocumentBuilder() {
@Override
public void beginBlock(BlockType type, Attributes attributes) {
actualEventTypes.add(type);
}
@Override
public void beginSpan(SpanType type, Attributes attributes) {
actualEventTypes.add(type);
}
@Override
public void characters(String text) {
actualEventTypes.add(text);
}
@Override
public void endBlock() {
actualEventTypes.add(END_BLOCK);
}
@Override
public void endSpan() {
actualEventTypes.add(END_SPAN);
}
};
parse(content, builder);
assertEquals(ImmutableList.copyOf(expectedEventTypes), actualEventTypes);
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType in project mylyn.docs by eclipse.
the class TracWikiLanguage method addStandardPhraseModifiers.
@Override
protected void addStandardPhraseModifiers(PatternBasedSyntax phraseModifierSyntax) {
// IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!!
phraseModifierSyntax.add(new MonospacePhraseModifier());
// always starts at the start of a line or after a non-word character excluding '!' and '-' //$NON-NLS-1$
phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.\\\"'?!;:\\)\\(\\{\\}\\[\\]-])|^)(?:", 0);
phraseModifierSyntax.add(new EscapePhraseModifier());
phraseModifierSyntax.add(new // $NON-NLS-1$
SimplePhraseModifier(// $NON-NLS-1$
"'''''", // $NON-NLS-1$
new SpanType[] { SpanType.BOLD, SpanType.ITALIC }, true));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("'''", SpanType.BOLD, true));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("''", SpanType.ITALIC, true));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("__", SpanType.UNDERLINED, true));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("~~", SpanType.DELETED, true));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("^", SpanType.SUPERSCRIPT, true));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier(",,", SpanType.SUBSCRIPT, true));
// $NON-NLS-1$
phraseModifierSyntax.endGroup(")(?=\\W|$)", 0);
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType in project mylyn.docs by eclipse.
the class TWikiLanguage method addStandardPhraseModifiers.
@Override
protected void addStandardPhraseModifiers(PatternBasedSyntax phraseModifierSyntax) {
// IMPORTANT NOTE: Most items below have order dependencies. DO NOT REORDER ITEMS BELOW!!
boolean escapingHtml = configuration == null ? false : configuration.isEscapingHtmlAndXml();
phraseModifierSyntax.add(new AutoLinkSwitchPhraseModifier());
if (!escapingHtml) {
phraseModifierSyntax.add(new HtmlStartTagPhraseModifier());
phraseModifierSyntax.add(new HtmlEndTagPhraseModifier());
}
// $NON-NLS-1$
phraseModifierSyntax.beginGroup("(?:(?<=[\\s\\.,\\\"'?!;:\\)\\(\\{\\}\\[\\]])|^)(?:", 0);
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("*", SpanType.BOLD));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("__", new SpanType[] { SpanType.BOLD, SpanType.ITALIC }));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("_", SpanType.ITALIC));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("==", new SpanType[] { SpanType.BOLD, SpanType.MONOSPACE }));
// $NON-NLS-1$
phraseModifierSyntax.add(new SimplePhraseModifier("=", SpanType.MONOSPACE));
// $NON-NLS-1$
phraseModifierSyntax.endGroup(")(?=\\W|$)", 0);
literalPhraseModifierSyntax.add(new HtmlStartTagPhraseModifier());
literalPhraseModifierSyntax.add(new HtmlEndTagPhraseModifier());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType in project mylyn.docs by eclipse.
the class SpanStrategiesTest method createNonEmpty.
@Test
public void createNonEmpty() {
SpanStrategies strategies = new SpanStrategies(Sets.newHashSet(SpanType.BOLD, SpanType.CODE), Collections.<SpanHtmlElementStrategy>emptyList());
assertSupported(strategies, SpanType.BOLD);
assertSupported(strategies, SpanType.CODE);
for (SpanType spanType : SpanType.values()) {
assertNotNull(strategies.getStrategy(spanType, new Attributes()));
}
}
Aggregations