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

Source information missing from parsed nodes #173

Open
rix0rrr opened this issue Sep 6, 2019 · 2 comments
Open

Source information missing from parsed nodes #173

rix0rrr opened this issue Sep 6, 2019 · 2 comments

Comments

@rix0rrr
Copy link

rix0rrr commented Sep 6, 2019

I'm making a renderer that will modify a tree in-place, but can roundtrip MarkDown back to the same MarkDown (or mostly the same).

There is some information missing from the parsed nodes that would be useful reconstructing the original document. In particular:

  • Whether a code_block was originally fenced or indented.
  • What symbol was used for emphasis, either * or _.

Can these be added to the parse nodes?

@jgm
Copy link
Member

jgm commented Sep 6, 2019

I'm unsure about this, because this is just the tip of the iceberg. Was a character escaped or not in the source? How much indentation was used before a list item? How many backticks were used in the code block? Was a reference or inline link used? Etc. Once you start going down this path, you're looking at a very different kind of parser output, a concrete syntax tree rather than an abstract one.

@88250
Copy link

88250 commented Sep 6, 2019

@rix0rrr

  • Node has a property _isFenced, but no marker char so can not determine marker is ` or ~
  • Emphasis has no marker char

You can add these on your fork. I wrote a parser with reference to commonmark.js, it added these 'meta info', you may take a look.

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

No branches or pull requests

3 participants