A extendable, lightweight, github compatible markdown compiler!
MIT License
npm install extendown
The libray is packaged in UMD, you can import it in ES6 modules, CommonJS, AMD, etc.
import Extendown from 'extendown';
const parse = Extendown.parse;
parse(YourMarkdownString);
the following code is extend a inline feature
const parse = Extendown.parse;
const extend = Extendown.extend;
const feature = {
reg: '==(.+?)==',
process(section) {
return section.replace(new RegExp(feature.reg, 'g'),
'<span style="background-color:yellow;">$1</span>');
},
}
extend(Extdown.INLINE, feature);
parse('==color==');
// <p><span style="background-color:yellow;">color</span></p>
the following code is extend a block feature
const feature = {
reg: '(?:^|\\n)@@\\n((?:[^@]*\\n)?)@@(?=\\n|$)',
process(section) {
return section.replace(new RegExp(feature.reg, 'g'), (match, g1) => {
return `<article>${g1}</article>`
});
},
};
extend(Extdown.BLOCK, feature);
parse(`@@
<p>here is your article</p>
@@`);
// <article><p>here is your article</p>\n</article>
The most config is for emoji, we will provide more config in future.
You can change emoji image's url in following ways.
config.emoji.path = 'https://dn-phphub.qbox.me/assets/images/emoji/';
config.emoji.ext = 'gif';
config.emoji.nameFormat = function(name) {
return `${name}test`;
};
Refer to Github Markdown