sstur / draft-js-utils

DraftJS: import/export ContentState to and from HTML/Markdown
ISC License
883 stars 233 forks source link

Remove marked fork from draft-js-import-markdown #162

Open mxstbr opened 5 years ago

mxstbr commented 5 years ago

...to avoid bugs like #161

mxstbr commented 5 years ago

I just tried doing this. Now I know why it is forked—marked does not have the ability to return an AST 😅

Soo, I guess we cannot use the package directly after all? Maybe there is a way to work around that by parsing the returned HTML to an AST with another package?

sstur commented 5 years ago

Ahh, now I remember! That's why I copied the code into this repo.

Hmm, I'd really hate to parse Markdown -> AST and then to HTML and then parse it again. I'd rather try to open a PR to marked seeing if we could expose an option or method to get the AST directly.

Failing that, we could fork it properly (as in Github repo), and try to make some minimal change which wouldn't conflict too much when we merge future upstream changes into our fork.

I'll look at it this weekend if I can.

sstur commented 5 years ago

So looking at the source code now, the idea of string concatenation is quite deeply baked into the parser. It could be turned into a more modular approach, but we'd end up re-writing half the library. I'm wondering if there's a better markdown parser to use. Will look into it.

sstur commented 5 years ago

I think we probably want this parser, which is part of the remark library and is used in Gatsby and others.

mxstbr commented 5 years ago

Yeah, the whole remark ecosystem (including mdx which is just amazing) is awesome. If that lib can work for us that'd be amazing!