mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
20 lines
683 B
JavaScript
20 lines
683 B
JavaScript
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);
|
|
};
|
|
}; |