A simple JSON to Markdown converter that transforms JSON data into easily readable text.
Import the module and use it in your code:
import { Converter } from '@kklab/json2markdown';
const output = Converter.toMarkdown({
'Hello, World!': 'It works!',
}, {
onConvert: (element) => {
if (element.tag === 'heading') {
element.level += 1;
}
return element;
},
});
console.log(output);
// Output:
// ## Hello, World!\n\nIt works!\n\n
Include the UMD script in your HTML file and use it:
<script src="https://unpkg.com/@kklab/json2markdown/dist/index.umd.js"></script>
<script>
const output = window.JSON2MD.Converter.toMarkdown({
'Hello, World!': 'It works!',
}, {
onConvert: (element) => {
if (element.tag === 'heading') {
element.level += 1;
}
return element;
},
});
console.log(JSON.stringify(output));
// Output:
// ## Hello, World!\n\nIt works!\n\n
</script>
To start a local development server, run:
npm run dev
To run the tests for this package, run:
npm run test