2019-03-13 00:07:02 +02:00
|
|
|
function installRule(markdownIt, mdOptions, ruleOptions) {
|
2019-07-29 15:43:53 +02:00
|
|
|
const defaultRender =
|
|
|
|
markdownIt.renderer.rules.code_inline ||
|
|
|
|
function(tokens, idx, options, env, self) {
|
|
|
|
return self.renderToken(tokens, idx, options);
|
|
|
|
};
|
2019-03-13 00:07:02 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
2019-07-29 15:43:53 +02:00
|
|
|
};
|