flexmark-java
flexmark-java copied to clipboard
Can I mix Gitlab extension with Pegdown extension?
I like to use katex and mermaid features in Gitlab extension from my pergdown based application. Is it possible to use both Pegdown and Gitlab extensions. If yes, how to setup the Parser? I am using the standard way in the example to setup the pegdown extensions:
static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(
Extensions.ALL
);
static Parser PARSER = Parser.builder(OPTIONS).build();
static HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
I have not been able to hook in the:
final private static DataHolder OPTIONS = new MutableDataSet()
.set(Parser.EXTENSIONS, Collections.singleton(GitLabExtension.create()))
.set(Parser.LISTS_AUTO_LOOSE, false)
.toImmutable();
Any help would be greatly appreciated.
You can provide a list of extensions to add to Pegdown flags:
Here is a function for flexmarkOptions, you have extensions which will be added:
public static DataHolder flexmarkOptions(int pegdownExtensions, Extension... extensions) {
return flexmarkOptions(false, pegdownExtensions, extensions);
}
For example:
final private static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(Extensions.ALL, CustomExtension.create());
To add/change option flags you can use the return value and convert it to mutable via .toMutable()
, make your changes and then convert back to immutable via .toImmutable()
For example:
static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(
Extensions.ALL,
GitLabExtension.create()
).toMutable()
.set(Parser.LISTS_AUTO_LOOSE, false)
.toImmutable();