mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Clean up
This commit is contained in:
parent
9f7ea7d865
commit
61c09f5bf8
@ -112,7 +112,6 @@ describe('MdToHtml', function() {
|
||||
const mdToHtml = newTestMdToHtml({ pluginOptions: pluginOptions });
|
||||
|
||||
const assets = await mdToHtml.allAssets(themeStyle(1));
|
||||
console.info('ASSETS', assets);
|
||||
expect(assets.length).toBe(2);
|
||||
expect(assets[1].mime).toBe('text/css');
|
||||
|
||||
|
@ -16,7 +16,6 @@ process.on('unhandledRejection', (reason, p) => {
|
||||
});
|
||||
|
||||
const testPluginDir = `${__dirname}/../tests/support/plugins`;
|
||||
const testContentScriptDir = `${__dirname}/../tests/support/pluginContentScripts`;
|
||||
|
||||
function newPluginService() {
|
||||
const runner = new PluginRunner();
|
||||
@ -155,8 +154,8 @@ describe('services_PluginService', function() {
|
||||
}));
|
||||
|
||||
it('should register a Markdown-it plugin', asyncTest(async () => {
|
||||
const contentScriptPath = `${Setting.value('tempDir')}/markdownItPluginTest_${uuid.createNano()}.js`;
|
||||
await shim.fsDriver().copy(`${testContentScriptDir}/markdownItPluginTest.js`, contentScriptPath);
|
||||
const contentScriptPath = `${Setting.value('tempDir')}/markdownItTestPlugin${uuid.createNano()}.js`;
|
||||
await shim.fsDriver().copy(`${testPluginDir}/content_script/src/markdownItTestPlugin.js`, contentScriptPath);
|
||||
|
||||
const service = newPluginService();
|
||||
|
||||
@ -188,7 +187,7 @@ describe('services_PluginService', function() {
|
||||
const contentScript = contentScripts[0];
|
||||
|
||||
const mdToHtml = new MdToHtml();
|
||||
const module = require(contentScript.path);
|
||||
const module = require(contentScript.path).default;
|
||||
mdToHtml.loadExtraRendererRule(contentScript.id, module({}));
|
||||
|
||||
const result = await mdToHtml.render([
|
||||
|
@ -1,22 +0,0 @@
|
||||
function installRule(markdownIt, mdOptions, ruleOptions, context) {
|
||||
const defaultRender = markdownIt.renderer.rules.fence || function(tokens, idx, options, env, self) {
|
||||
return self.renderToken(tokens, idx, options, env, self);
|
||||
};
|
||||
|
||||
markdownIt.renderer.rules.fence = function(tokens, idx, options, env, self) {
|
||||
const token = tokens[idx];
|
||||
if (token.info !== 'justtesting') return defaultRender(tokens, idx, options, env, self);
|
||||
return `JUST TESTING: ${token.content}`;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function(pluginContext) {
|
||||
return {
|
||||
install: function(context, ruleOptions) {
|
||||
return function(md, mdOptions) {
|
||||
installRule(md, mdOptions, ruleOptions, context);
|
||||
};
|
||||
},
|
||||
assets: {},
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function installRule(markdownIt, mdOptions, ruleOptions, context) {
|
||||
function plugin(markdownIt, _options) {
|
||||
const defaultRender = markdownIt.renderer.rules.fence || function(tokens, idx, options, env, self) {
|
||||
return self.renderToken(tokens, idx, options, env, self);
|
||||
};
|
||||
@ -10,13 +10,10 @@ function installRule(markdownIt, mdOptions, ruleOptions, context) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function(pluginContext) {
|
||||
return {
|
||||
install: function(context, ruleOptions) {
|
||||
return function(md, mdOptions) {
|
||||
installRule(md, mdOptions, ruleOptions, context);
|
||||
};
|
||||
},
|
||||
assets: {},
|
||||
}
|
||||
module.exports = {
|
||||
default: function(_context) {
|
||||
return {
|
||||
plugin: plugin,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ export default class MdToHtml {
|
||||
|
||||
let cssStrings = noteStyle(options.theme);
|
||||
|
||||
let output = { ...this.allProcessedAssets(theme, options.codeTheme) };
|
||||
let output = { ...this.allProcessedAssets(options.theme, options.codeTheme) };
|
||||
cssStrings = cssStrings.concat(output.cssStrings);
|
||||
|
||||
if (options.userCss) cssStrings.push(options.userCss);
|
||||
|
@ -1,7 +1,19 @@
|
||||
/* global mermaid */
|
||||
|
||||
function mermaidReady() {
|
||||
return typeof mermaid !== 'undefined';
|
||||
// The Mermaid initialization code renders the Mermaid code within any element with class "mermaid" or
|
||||
// ID "mermaid". However in some cases some elements might have this ID but not be Mermaid code.
|
||||
// For example, Markdown code like this:
|
||||
//
|
||||
// # Mermaid
|
||||
//
|
||||
// Will generate this HTML:
|
||||
//
|
||||
// <h1 id="mermaid">Mermaid</h1>
|
||||
//
|
||||
// And that's going to make the lib set the `mermaid` object to the H1 element.
|
||||
// So below, we double-check that what we have really is an instance of the library.
|
||||
return typeof mermaid !== 'undefined' && mermaid !== null && typeof mermaid === 'object' && !!mermaid.init;
|
||||
}
|
||||
|
||||
function mermaidInit() {
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,19 @@
|
||||
/* global mermaid */
|
||||
|
||||
function mermaidReady() {
|
||||
return typeof mermaid !== 'undefined';
|
||||
// The Mermaid initialization code renders the Mermaid code within any element with class "mermaid" or
|
||||
// ID "mermaid". However in some cases some elements might have this ID but not be Mermaid code.
|
||||
// For example, Markdown code like this:
|
||||
//
|
||||
// # Mermaid
|
||||
//
|
||||
// Will generate this HTML:
|
||||
//
|
||||
// <h1 id="mermaid">Mermaid</h1>
|
||||
//
|
||||
// And that's going to make the lib set the `mermaid` object to the H1 element.
|
||||
// So below, we double-check that what we have really is an instance of the library.
|
||||
return typeof mermaid !== 'undefined' && mermaid !== null && typeof mermaid === 'object' && !!mermaid.init;
|
||||
}
|
||||
|
||||
function mermaidInit() {
|
||||
|
@ -10,7 +10,7 @@ export default function contentScriptsToRendererRules(plugins:PluginStates):Extr
|
||||
const contentScripts = plugin.contentScripts[scriptType];
|
||||
for (const contentScript of contentScripts) {
|
||||
|
||||
const loadedModule = require(contentScript.path);
|
||||
const loadedModule = require(contentScript.path).default;
|
||||
|
||||
output.push({
|
||||
id: contentScript.id,
|
||||
|
Loading…
Reference in New Issue
Block a user