Search in sources :

Example 1 with SpanType

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();
        }
    };
}
Also used : SpanType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) PatternBasedElementProcessor(org.eclipse.mylyn.wikitext.parser.markup.PatternBasedElementProcessor)

Example 2 with SpanType

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);
}
Also used : NoOpDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder) SpanType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType) DocumentBuilder(org.eclipse.mylyn.wikitext.parser.DocumentBuilder) NoOpDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) BlockType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType) ArrayList(java.util.ArrayList) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes)

Example 3 with SpanType

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);
}
Also used : SpanType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType) MonospacePhraseModifier(org.eclipse.mylyn.wikitext.tracwiki.internal.phrase.MonospacePhraseModifier) EscapePhraseModifier(org.eclipse.mylyn.wikitext.tracwiki.internal.phrase.EscapePhraseModifier) SimplePhraseModifier(org.eclipse.mylyn.wikitext.tracwiki.internal.phrase.SimplePhraseModifier)

Example 4 with SpanType

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());
}
Also used : SpanType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType) AutoLinkSwitchPhraseModifier(org.eclipse.mylyn.wikitext.twiki.internal.phrase.AutoLinkSwitchPhraseModifier) SimplePhraseModifier(org.eclipse.mylyn.wikitext.twiki.internal.phrase.SimplePhraseModifier) HtmlEndTagPhraseModifier(org.eclipse.mylyn.wikitext.parser.markup.phrase.HtmlEndTagPhraseModifier) HtmlStartTagPhraseModifier(org.eclipse.mylyn.wikitext.parser.markup.phrase.HtmlStartTagPhraseModifier)

Example 5 with SpanType

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()));
    }
}
Also used : SpanType(org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) SpanStrategies(org.eclipse.mylyn.wikitext.html.internal.SpanStrategies) Test(org.junit.Test)

Aggregations

SpanType (org.eclipse.mylyn.wikitext.parser.DocumentBuilder.SpanType)6 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)3 ArrayList (java.util.ArrayList)1 SpanStrategies (org.eclipse.mylyn.wikitext.html.internal.SpanStrategies)1 EscapePhraseModifier (org.eclipse.mylyn.wikitext.mediawiki.internal.phrase.EscapePhraseModifier)1 SimplePhraseModifier (org.eclipse.mylyn.wikitext.mediawiki.internal.phrase.SimplePhraseModifier)1 DocumentBuilder (org.eclipse.mylyn.wikitext.parser.DocumentBuilder)1 BlockType (org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType)1 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)1 NoOpDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder)1 PatternBasedElementProcessor (org.eclipse.mylyn.wikitext.parser.markup.PatternBasedElementProcessor)1 HtmlCommentPhraseModifier (org.eclipse.mylyn.wikitext.parser.markup.phrase.HtmlCommentPhraseModifier)1 HtmlEndTagPhraseModifier (org.eclipse.mylyn.wikitext.parser.markup.phrase.HtmlEndTagPhraseModifier)1 HtmlStartTagPhraseModifier (org.eclipse.mylyn.wikitext.parser.markup.phrase.HtmlStartTagPhraseModifier)1 LimitedHtmlEndTagPhraseModifier (org.eclipse.mylyn.wikitext.parser.markup.phrase.LimitedHtmlEndTagPhraseModifier)1 LimitedHtmlStartTagPhraseModifier (org.eclipse.mylyn.wikitext.parser.markup.phrase.LimitedHtmlStartTagPhraseModifier)1 EscapePhraseModifier (org.eclipse.mylyn.wikitext.tracwiki.internal.phrase.EscapePhraseModifier)1 MonospacePhraseModifier (org.eclipse.mylyn.wikitext.tracwiki.internal.phrase.MonospacePhraseModifier)1 SimplePhraseModifier (org.eclipse.mylyn.wikitext.tracwiki.internal.phrase.SimplePhraseModifier)1 AutoLinkSwitchPhraseModifier (org.eclipse.mylyn.wikitext.twiki.internal.phrase.AutoLinkSwitchPhraseModifier)1