@Override public void visit(TypographicSmarts node) { visitor.visit(node); } }),
@Override protected String toStringAttributes() { return "text=" + getChars(); } }
public static Extension create() { return new TypographicExtension(); }
@Override public void process(Delimiter opener, Delimiter closer, int delimitersUsed) { // Normal case, wrap nodes between delimiters in strikethrough. TypographicQuotes node = new TypographicQuotes(opener.getTailChars(delimitersUsed), BasedSequence.NULL, closer.getLeadChars(delimitersUsed)); node.setTypographicOpening(myOpener); node.setTypographicClosing(myCloser); opener.moveNodesBetweenDelimitersTo(node, closer); } }
private void render(TypographicQuotes node, NodeRendererContext context, HtmlWriter html) { if (node.getTypographicOpening() != null && !node.getTypographicOpening().isEmpty()) html.raw(node.getTypographicOpening()); context.renderChildren(node); if (node.getTypographicClosing() != null && !node.getTypographicClosing().isEmpty()) html.raw(node.getTypographicClosing()); }
@Override public Node unmatchedDelimiterNode(InlineParser inlineParser, final DelimiterRun delimiter) { if (myUnmatched != null && myOptions.typographicSmarts) { BasedSequence chars = delimiter.getNode().getChars(); if (chars.length() == 1) { return new TypographicSmarts(chars, myUnmatched); } } return null; }
extensions.add(TypographicExtension.create()); options.set(TypographicExtension.ENABLE_SMARTS, haveExtensions(SMARTS)); options.set(TypographicExtension.ENABLE_QUOTES, haveExtensions(QUOTES));
private void render(TypographicSmarts node, NodeRendererContext context, HtmlWriter html) { html.raw(node.getTypographicText()); }
@Override public void getAstExtra(StringBuilder out) { if (openingMarker.isNotNull()) out.append(" typographicOpening: ").append(typographicOpening).append(" "); if (closingMarker.isNotNull()) out.append(" typographicClosing: ").append(typographicClosing).append(" "); delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); }
@Override public void visit(TypographicQuotes node1) { visitor.visit(node1); } }),
@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; }
extensions.add(TypographicExtension.create()); options.set(TypographicExtension.ENABLE_SMARTS, haveExtensions(SMARTS)); options.set(TypographicExtension.ENABLE_QUOTES, haveExtensions(QUOTES));