Search in sources :

Example 6 with Extension

use of com.vladsch.flexmark.Extension in project flexmark-java by vsch.

the class Parser method removeExtensions.

/**
 * Remove extension(s) of given class from the extension list
 *
 * @param options    mutable options holding existing extensions
 * @param extensions extension classes to remove
 * @return mutable options
 */
public static MutableDataHolder removeExtensions(MutableDataHolder options, Class... extensions) {
    Iterable<Extension> extensionIterable = options.get(Parser.EXTENSIONS);
    HashSet<Extension> extensionList = new HashSet<Extension>();
    for (Extension extension : extensionIterable) {
        boolean keep = true;
        for (Class clazz : extensions) {
            if (clazz.isInstance(extension)) {
                keep = false;
                break;
            }
        }
        if (keep) {
            extensionList.add(extension);
        }
    }
    options.set(Parser.EXTENSIONS, extensionList);
    return options;
}
Also used : Extension(com.vladsch.flexmark.Extension)

Aggregations

Extension (com.vladsch.flexmark.Extension)6 MutableDataSet (com.vladsch.flexmark.util.options.MutableDataSet)4 Node (com.vladsch.flexmark.ast.Node)2 AutolinkExtension (com.vladsch.flexmark.ext.autolink.AutolinkExtension)2 FootnoteExtension (com.vladsch.flexmark.ext.footnotes.FootnoteExtension)2 TocExtension (com.vladsch.flexmark.ext.toc.TocExtension)2 HtmlRenderer (com.vladsch.flexmark.html.HtmlRenderer)2 Parser (com.vladsch.flexmark.parser.Parser)2 MutableDataHolder (com.vladsch.flexmark.util.options.MutableDataHolder)2 AbbreviationExtension (com.vladsch.flexmark.ext.abbreviation.AbbreviationExtension)1 AnchorLinkExtension (com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension)1 DefinitionExtension (com.vladsch.flexmark.ext.definition.DefinitionExtension)1 EscapedCharacterExtension (com.vladsch.flexmark.ext.escaped.character.EscapedCharacterExtension)1 StrikethroughExtension (com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension)1 StrikethroughSubscriptExtension (com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughSubscriptExtension)1 SubscriptExtension (com.vladsch.flexmark.ext.gfm.strikethrough.SubscriptExtension)1 TaskListExtension (com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension)1 InsExtension (com.vladsch.flexmark.ext.ins.InsExtension)1 TablesExtension (com.vladsch.flexmark.ext.tables.TablesExtension)1 SimTocExtension (com.vladsch.flexmark.ext.toc.SimTocExtension)1