This is a fork form Shogobg/markdown2confluence, Thanks for
Shogobg
to provide such goof util and i wanna do some refactors with markdown ast utils.
This tool converts [Markdown] to [Confluence Wiki Markup].
npm i -g md2cwm
npm i --save md2cwm
Read in Markdown files and allow to use glob
md2c *.md <path/to/docs>
// md2cwm the same
Now you write some JavaScript to load Markdown content and convert.
const md2cwm = require('md2cwm');
const markdown = fs.readFileSync('README.md');
const confluence = md2cwm(markdown);
console.log(confluence);
This uses the wonderful marked library to parse and reformat the Markdown text.
Since this tool uses marked, there is a pre-defined renderer which we pass to marked. If you want to replace any of the predefined functions or the renderer as a whole, you can do so by passing an options object to the tool.
md2cwm = require('md2cwm');
markdown = fs.readFileSync('README.md');
confluence = md2cwm(markdown, {
renderer: {
link: href => {
return `http://example.com/${href}`;
},
},
});
console.log(confluence);
Additionally, the options objects takes custom arguments for the confluence code block options.
md2cwm = require('md2cwm');
markdown = fs.readFileSync('README.md');
confluence = md2cwm(markdown, {
renderer: {
link: href => {
return `http://example.com/${href}`;
},
},
codeBlock: {
// Adds support for new language
languageMap: {
leet: '1337',
},
// Shows the supported options and their default values
options: {
title: 'none',
language: 'none',
borderStyle: 'solid',
theme: 'RDark', // dark is good
linenumbers: true,
collapse: true,
},
},
});
console.log(confluence);