mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-04 19:16:07 +02:00
All: Fixes #1326: Restored inline code styling
This commit is contained in:
parent
54f0fbcf6b
commit
1030b412ff
@ -15,6 +15,7 @@ const rules = {
|
||||
html_block: require('./MdToHtml/rules/html_block'),
|
||||
html_inline: require('./MdToHtml/rules/html_inline'),
|
||||
highlight_keywords: require('./MdToHtml/rules/highlight_keywords'),
|
||||
code_inline: require('./MdToHtml/rules/code_inline'),
|
||||
};
|
||||
const setupLinkify = require('./MdToHtml/setupLinkify');
|
||||
const hljs = require('highlight.js');
|
||||
@ -75,12 +76,30 @@ class MdToHtml {
|
||||
|
||||
const ruleOptions = Object.assign({}, options, { resourceBaseUrl: this.resourceBaseUrl_ });
|
||||
|
||||
// To add a plugin, there are two options:
|
||||
//
|
||||
// 1. If the plugin does not need any application specific data, use the standard way:
|
||||
//
|
||||
// const someMarkdownPlugin = require('someMarkdownPlugin');
|
||||
// markdownIt.use(someMarkdownPlugin);
|
||||
//
|
||||
// 2. If the plugin needs application data (in ruleOptions) or needs to pass data (CSS, files to load, etc.) back
|
||||
// to the application (using the context object), use the application-specific way:
|
||||
//
|
||||
// const imagePlugin = require('./MdToHtml/rules/image');
|
||||
// markdownIt.use(imagePlugin(context, ruleOptions));
|
||||
//
|
||||
// Using the `context` object, a plugin can send back either CSS strings (in .css) or CSS files that need
|
||||
// to be loaded (in .cssFiles). In general, the desktop app will load the CSS files and the mobile app
|
||||
// will load the CSS strings.
|
||||
|
||||
markdownIt.use(rules.image(context, ruleOptions));
|
||||
markdownIt.use(rules.checkbox(context, ruleOptions));
|
||||
markdownIt.use(rules.link_open(context, ruleOptions));
|
||||
markdownIt.use(rules.html_block(context, ruleOptions));
|
||||
markdownIt.use(rules.katex(context, ruleOptions));
|
||||
markdownIt.use(rules.highlight_keywords(context, ruleOptions));
|
||||
markdownIt.use(rules.code_inline(context, ruleOptions));
|
||||
|
||||
setupLinkify(markdownIt);
|
||||
|
||||
|
20
ReactNativeClient/lib/MdToHtml/rules/code_inline.js
Normal file
20
ReactNativeClient/lib/MdToHtml/rules/code_inline.js
Normal file
@ -0,0 +1,20 @@
|
||||
function installRule(markdownIt, mdOptions, ruleOptions) {
|
||||
const defaultRender = markdownIt.renderer.rules.code_inline || function(tokens, idx, options, env, self) {
|
||||
return self.renderToken(tokens, idx, options);
|
||||
};
|
||||
|
||||
markdownIt.renderer.rules.code_inline = (tokens, idx, options, env, self) => {
|
||||
const token = tokens[idx];
|
||||
let tokenClass = token.attrGet('class');
|
||||
if (!tokenClass) tokenClass = '';
|
||||
tokenClass += ' inline-code';
|
||||
token.attrSet('class', tokenClass.trim());
|
||||
return defaultRender(tokens, idx, options, env, self);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function(context, ruleOptions) {
|
||||
return function(md, mdOptions) {
|
||||
installRule(md, mdOptions, ruleOptions);
|
||||
};
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user