Search in sources :

Example 1 with TocBlock

use of com.vladsch.flexmark.ext.toc.TocBlock in project jspwiki by apache.

the class PluginLinkNodePostProcessorState method handleTableOfContentsPlugin.

void handleTableOfContentsPlugin(final NodeTracker state, final JSPWikiLink link) {
    if (!m_wysiwygEditorMode) {
        final ResourceBundle rb = Preferences.getBundle(wikiContext, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
        final HtmlInline divToc = new HtmlInline(CharSubSequence.of("<div class=\"toc\">\n"));
        final HtmlInline divCollapseBox = new HtmlInline(CharSubSequence.of("<div class=\"collapsebox\">\n"));
        final HtmlInline divsClosing = new HtmlInline(CharSubSequence.of("</div>\n</div>\n"));
        final HtmlInline h4Title = new HtmlInline(CharSubSequence.of(// FIXME proper plugin parameters handling
        "<h4 id=\"section-TOC\">" + rb.getString("tableofcontents.title") + "</h4>\n"));
        final TocBlock toc = new TocBlock(CharSubSequence.of("[TOC]"), CharSubSequence.of("levels=1-3"));
        link.insertAfter(divToc);
        divToc.insertAfter(divCollapseBox);
        divCollapseBox.insertAfter(h4Title);
        h4Title.insertAfter(toc);
        toc.insertAfter(divsClosing);
    } else {
        NodePostProcessorStateCommonOperations.inlineLinkTextOnWysiwyg(state, link, m_wysiwygEditorMode);
    }
    removeLink(state, link);
}
Also used : HtmlInline(com.vladsch.flexmark.ast.HtmlInline) ResourceBundle(java.util.ResourceBundle) TocBlock(com.vladsch.flexmark.ext.toc.TocBlock)

Aggregations

HtmlInline (com.vladsch.flexmark.ast.HtmlInline)1 TocBlock (com.vladsch.flexmark.ext.toc.TocBlock)1 ResourceBundle (java.util.ResourceBundle)1