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

Improved Concrete Syntax Trees #59

Closed
benrbray opened this issue May 18, 2021 · 5 comments
Closed

Improved Concrete Syntax Trees #59

benrbray opened this issue May 18, 2021 · 5 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@benrbray
Copy link

benrbray commented May 18, 2021

Subject of the feature

I'm in the process of migrating my markdown editor to use remark/micromark instead of markdown-it. One of my goals is not to change the formatting style of my users' input files, at least if I can help it.

At the moment, the micromark tokenizers seem not to record information that might help reconstruct the original input Markdown in cases where Markdown has redundancies:

  • _ vs * for emphasis
  • ATX headings vs setext headings
  • * vs - vs + for unordered lists
  • * vs - vs = for hrule / thematic breaks, as well as the length of the string used to indicate the break

I'm not terribly interested in preserving superfluous whitespace the user might have, but it would be nice to at least preserve their preferences for emphasis / heading / list syntax. For instance, I personally like to use * for regular lists and +/- for pro/con lists, and at the moment there's no way to preserve that information.

  • Are there any plans for improved concrete syntax tree support in the future?
  • If not would PRs be welcome to record syntactic information on syntax tree nodes, as well as in the corresponding serializers?
  • Otherwise, any advice for implementing this feature as a set of plugins would be appreciated!

Thanks!

Problem

Expected behavior

Alternatives

@benrbray benrbray added the 🦋 type/enhancement This is great to have label May 18, 2021
@github-actions github-actions bot added the 👋 phase/new Post is being triaged automatically label May 18, 2021
@github-actions

This comment has been minimized.

@wooorm
Copy link
Member

wooorm commented May 18, 2021

^-- this is my fault I think

@wooorm wooorm added 🙋 no/question This does not need any changes and removed 🦋 type/enhancement This is great to have labels May 18, 2021
@wooorm
Copy link
Member

wooorm commented May 18, 2021

Are there any plans for improved concrete syntax tree support in the future?

It would mean a different syntax tree that is hard to manage as it is so verbose.
micromark was made to allow making a CST. There have been several discussions about it over the years: https://github.com/search?q=CST+user%3Awooorm+user%3Amicromark+user%3Aremarkjs+user%3Asyntax-tree&type=Issues
It would be cool to have, but it’s also a ginormous effort to design a concrete syntax tree, and would affect many things in unified.

If not would PRs be welcome to record syntactic information on syntax tree nodes, as well as in the corresponding serializers?

I’m against adding such information on abstract syntax tree nodes, as I think ASTs by definition should not have such information: they’re supposed to be lossy and easy to handle.

Otherwise, any advice for implementing this feature as a set of plugins would be appreciated!

You can detect such information, similar to how remark-lint detects such information, in a plugin. It could record that information and turn it into an object that mdast-util-to-markdown expects

@wooorm wooorm closed this as completed May 18, 2021
@github-actions
Copy link

Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.

See our support docs for how and where to ask questions.

Thanks,
— bb

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 👋 phase/new Post is being triaged automatically labels May 18, 2021
@github-actions

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants