Search in sources :

Example 1 with TypographicSmarts

use of com.vladsch.flexmark.ext.typographic.TypographicSmarts in project flexmark-java by vsch.

the class SmartsInlineParser method parse.

@Override
public boolean parse(final InlineParser inlineParser) {
    BasedSequence match = inlineParser.match(parsing.SMARTS);
    if (match != null) {
        BasedSequence input = inlineParser.getInput();
        inlineParser.flushTextNode();
        String typographicSmarts;
        if (match.matches(parsing.ELIPSIS))
            typographicSmarts = "…";
        else if (match.matches(parsing.ELIPSIS_SPACED))
            typographicSmarts = "…";
        else if (match.matches(parsing.EN_DASH))
            typographicSmarts = "–";
        else if (match.matches(parsing.EM_DASH))
            typographicSmarts = "—";
        else
            return false;
        TypographicSmarts smarts = new TypographicSmarts(match, typographicSmarts);
        inlineParser.getBlock().appendChild(smarts);
        return true;
    }
    return false;
}
Also used : BasedSequence(com.vladsch.flexmark.util.sequence.BasedSequence) TypographicSmarts(com.vladsch.flexmark.ext.typographic.TypographicSmarts)

Aggregations

TypographicSmarts (com.vladsch.flexmark.ext.typographic.TypographicSmarts)1 BasedSequence (com.vladsch.flexmark.util.sequence.BasedSequence)1