@kklab/json2markdown
v0.0.17
Published
A simple JSON to Markdown converter that transforms JSON data into easily readable text.
Downloads
659
Readme
json2markdown
A simple JSON to Markdown converter that transforms JSON data into easily readable text.
Usage
Using with ES Modules
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
Using with UMD Modules
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>
Development
To start a local development server, run:
npm run dev
Testing
To run the tests for this package, run:
npm run test