Search in sources :

Example 1 with AnchorLink

use of com.vladsch.flexmark.ext.anchorlink.AnchorLink in project flexmark-java by vsch.

the class AnchorLinkNodePostProcessor method process.

@Override
public void process(NodeTracker state, Node node) {
    if (node instanceof Heading) {
        if (node.isOrDescendantOfType(BlockQuote.class)) {
            int tmp = 0;
        }
        Heading heading = (Heading) node;
        if (heading.getText().isNotNull()) {
            Node anchor = new AnchorLink();
            if (!options.wrapText) {
                if (heading.getFirstChild() == null) {
                    anchor.setChars(heading.getText().subSequence(0, 0));
                    heading.appendChild(anchor);
                } else {
                    anchor.setChars(heading.getFirstChild().getChars().subSequence(0, 0));
                    heading.getFirstChild().insertBefore(anchor);
                }
            } else {
                anchor.takeChildren(heading);
                heading.appendChild(anchor);
            }
            anchor.setCharsFromContent();
            state.nodeAdded(anchor);
        }
    } else {
        int tmp = 0;
    }
}
Also used : AnchorLink(com.vladsch.flexmark.ext.anchorlink.AnchorLink) Heading(com.vladsch.flexmark.ast.Heading) Node(com.vladsch.flexmark.ast.Node)

Aggregations

Heading (com.vladsch.flexmark.ast.Heading)1 Node (com.vladsch.flexmark.ast.Node)1 AnchorLink (com.vladsch.flexmark.ext.anchorlink.AnchorLink)1