-
Notifications
You must be signed in to change notification settings - Fork 262
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
Header attributes #4
Comments
Thanks, I've fixed the issue. |
@yuin, didn't you consider to avoid closing # signs during atriibutes {container} extraction? The most common syntax is
In fact, I've never seen anyone use markup like https://github.com/yuin/goldmark/blob/master/parser/atx_heading.go#L96 |
I do not consider to avoid closing
I'm planning to implement attributes for other elements, but it is ambivalent what forms is the best. |
DITA: https://github.com/jelovirt/org.lwdita/blob/master/src/test/resources/markdown/header_attributes.md A have seen a lot of MD docs and in fact most of them use This is quite an important case, so I pay such attention to it. |
You right, but CommonMark includes many many such "really rare cases" . This is why markdown parsers based on CommonMark barely exist. And ignoring such rare cases is why markdown has so many dialects and less compatibility. CommonMark does not accept spec only because "it is de facto standard" . If not, discussion about attributes can not continue for several years. goldmark has basically the same policy. Your example includes attributes for other elements. If we have attributes for other element, we probably can parse consistently. But If we implement this feature now , it will be an ad-hoc implementation. Look, I do not say "I'm not planning to implement this feature". This should be designed more carefully including attributes for other elements and it probably take time. |
Got it, thank you. But extra space in headings still alive. |
I've fixed invalid leading spaces. About attributes, in addition, header ids currently do not support multiline attributes. If we support muiltiline attributes, things will be more complex.
This is very hard to parse. Honestly, I hesitated implementing header attributes because I can not implement attributes consistently. One possible solution is allowing multiple attributes on one element but one attribute must be on single line.
This style of attributes are easy to parse. If we found '{' on the line head in block parsing phase, we try to parse this line as an attribute. If we can parse it and there are no blank lines before it, this attribute belongs previous sibling. |
I've got many stars unexpectedly yesterday, so this project will possibly be used in many projects. I know that many users need header ids without closing '#', so I've added your requested feature anyhow. But as described above, the attribute syntax is being discussed in the CommonMark forum.
|
You are absolutely right to think carefully about supporting the attributes of any element. But header attributes is probably one of the most important and probably the most simple case. Header is always a single line, and HeaderAttributes is an extension out of commonmark spec. This extension can be based on the agremeent that https://spec.commonmark.org/0.29/#atx-heading Look here - that's how Jarno do it for DITA-OT. I do not mean that regex is needed. Talking about markdown in general... Markdown isn't either extendable or structured by design. This is for easy read / easy write. It seems to me that a new language should appear. Probably, it will be something between MD and RST. Your syntax
->
->
I've expected it :) I want to congratulate you on your success. When I saw your code, I was very impressed. And I hope that this project will have a long and happy life. |
It seems that parser.WithAttribute() pocessinп does not always work well.
https://github.com/mironovalexey/gm-test/tree/master/hattrs
https://github.com/mironovalexey/gm-test/blob/master/hattrs/test.md
The text was updated successfully, but these errors were encountered: