Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Markdown Strings to Json Object #16

Open
yonderbread opened this issue Sep 4, 2020 · 7 comments
Open

Parse Markdown Strings to Json Object #16

yonderbread opened this issue Sep 4, 2020 · 7 comments

Comments

@yonderbread
Copy link

Instead of reading in files, would I be able to parse some strings with this and convert them to objects?

@klaytonfaria
Copy link
Owner

@yonderbread , thanks for the suggestion. Could you please give more details about the string input usage?

@yonderbread
Copy link
Author

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.

@johnbeech
Copy link

johnbeech commented Sep 10, 2021

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)

@yonderbread
Copy link
Author

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.

@uarefans
Copy link

uarefans commented Mar 3, 2022

maybe this is solution to not convert markdown to html

  1. Open lib/generator.js
  2. Edit line 125
  3. Give comment
    // .use(markdown())
  4. Save and run again

@yonderbread
Copy link
Author

yonderbread commented Mar 14, 2022

Gonna try to test some things out. Feel free to open a pull request on my fork.

@uarefans
Copy link

uarefans commented Apr 14, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants