markdown-json
markdown-json copied to clipboard
Parse Markdown Strings to Json Object
Instead of reading in files, would I be able to parse some strings with this and convert them to objects?
@yonderbread , thanks for the suggestion. Could you please give more details about the string input usage?
Yea of course, so instead of reading directly from a file object you could just pass an already read out file as a string to markdown-json and it would return the Object version of it.
Same sentiment from me - I wasn't looking for a server/file processor - I just wanted a function that would convert a markdown string to a JSON structure.
e.g.:
const markdownJson = require('markdown-json')
const fs = require('fs')
const markdown = fs.readFileSync('README.md', 'utf8')
const json = markdownJson.parse(markdown)
console.log(json)
Same sentiment from me - I wasn't looking for a server/file processor - I just wanted a function that would convert a markdown string to a JSON structure.
e.g.:
const markdownJson = require('markdown-json') const fs = require('fs') const markdown = fs.readFileSync('README.md', 'utf8') const json = markdownJson.parse(markdown) console.log(json)
Yup. That's what I remember wanting to do as well. If I find some time I will try to implement this into the library.
maybe this is solution to not convert markdown to html
- Open lib/generator.js
- Edit line 125
- Give comment
// .use(markdown()) - Save and run again
Gonna try to test some things out. Feel free to open a pull request on my fork.
Gonna try to test some things out. Feel free to open a pull request on my fork.
not
//.use(writeJson)
but
// .use(markdown())
Reference your file at line 123 and please test delete all generator.js and run node markdown-json again, you give error or not. This is important because if not show any error you are using global markdown-json not from github but from npm install markdown-json.
reinstall with
git clone https://github.com/klaytonfaria/markdown-json.git
cd markdown-json
npm install
edit lib/generator.js
node markdown-json