md2cwm
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

md2cwm

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].

Installation

npm i -g md2cwm
npm i --save md2cwm

Command-Line Use

Read in Markdown files and allow to use glob

md2c *.md <path/to/docs>
// md2cwm the same

As library dependency

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.

Custom options

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);

Package Sidebar

Install

npm i md2cwm

Weekly Downloads

30

Version

1.0.4

License

MIT

Unpacked Size

544 kB

Total Files

19

Last publish

Collaborators

  • icebreaker