You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Android: Add support for renderer plugins (#10135)
This commit is contained in:
@@ -548,12 +548,23 @@ export default class MdToHtml implements MarkupRenderer {
|
||||
|
||||
const allRules = { ...rules, ...this.extraRendererRules_ };
|
||||
|
||||
const loadPlugin = (plugin: any, options: any) => {
|
||||
// Handle the case where we're bundling with webpack --
|
||||
// some modules that are commonjs imports in nodejs
|
||||
// act like ES6 imports.
|
||||
if (typeof plugin !== 'function' && plugin.default) {
|
||||
plugin = plugin.default;
|
||||
}
|
||||
|
||||
markdownIt.use(plugin, options);
|
||||
};
|
||||
|
||||
for (const key in allRules) {
|
||||
if (!this.pluginEnabled(key)) continue;
|
||||
|
||||
const rule = allRules[key];
|
||||
|
||||
markdownIt.use(rule.plugin, {
|
||||
loadPlugin(rule.plugin, {
|
||||
context: context,
|
||||
...ruleOptions,
|
||||
...(ruleOptions.plugins[key] ? ruleOptions.plugins[key] : {}),
|
||||
@@ -563,11 +574,11 @@ export default class MdToHtml implements MarkupRenderer {
|
||||
});
|
||||
}
|
||||
|
||||
markdownIt.use(markdownItAnchor, { slugify: slugify });
|
||||
loadPlugin(markdownItAnchor, { slugify: slugify });
|
||||
|
||||
for (const key in plugins) {
|
||||
if (this.pluginEnabled(key)) {
|
||||
markdownIt.use(plugins[key].module, plugins[key].options);
|
||||
loadPlugin(plugins[key].module, plugins[key].options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user