-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add info
field to Code
block
#22
Add info
field to Code
block
#22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice! One thing I’m wondering is why not just use info
instead of infoString
?
:) No reason, it's as you wish
So i take infoString, in first place i taked "info-string" and it's definitively ugly. |
I would think that since the common mark spec refers to it as the |
2f3958c
to
009f984
Compare
For the language, it's "lang" so for the info string, the tag "info" doesn't seen weird. For the request, it's done (for the attribute's name too btw) |
Yeah I think I prefer |
Say we have this: ```js no-highlight
fn()
``` And we have the node for that code: {
type: 'code',
info: 'js no-highlight',
lang: 'js',
value: 'fn()'
} ...what if someone changed
|
I think that info should be the whole string. The main reason is that the definition of info string from GMF and CommonMark is the whole string. An other is that it's common to specify the language as the first word but it's not specified. Spec :
But as you notify, it can lead to inconsistent states. PS: Oups ! I miss clicked on close and comment ... >_<" |
I’d rather not specify something that could create inconsistencies, and IMO it makes sense to see: ~~~ ruby startline=3 $%@#$
~~~ to {
type: 'code',
lang: 'ruby',
info: 'startline=3 $%@#$'
} ...note, btw, I don’t think commonmark specifies what a “word” is in:
|
:( So it's more complicated. Now it need specifications 😢 So ... here we go ! ~~~js info
~~~
~~~js info
Trailing spaces before and after the info string are skipped
~~~
~~~js
No info string is null
~~~
Is it ok like that ? Edit: Easy spec, i don't want it to be too complicated. Can't handle complicated things. |
Yeah I think this is fine! I don’t believe we should care about spacing between @ChristianMurphy Any thoughts? |
So it would trim external space but not internal? ~~~ js something that has random spacing
~~~ would parse to {
"info": "something that has random spacing"
} rather than {
"info": "something that has random spacing"
} ?
Sounds good |
Actually here, we don't really care about words but the most important is that it can handle programming language names. That to Wikipedia, programming languages list. In the code i defined it by every char until a white space (\s) or a curly bracket (but we may add every kind of bracket). Yeap, it will trim extrernal but not internal spaces. Or maybe no trim at all ? The choice is yours. |
@ChristianMurphy Yup, that’s what I’m thinking of! |
@wooorm ? Border ? An example please ? Only white-space you mean ? Triming internal spaces can be tricky. ~~~js value=" i want it spaced "
~~~ |
@arobase-che I mean the “border” between lang and info. And I believe internal white-space should be kept as is. Just the “border” should be removed. |
Ok so :
But :
It become a problem with that :
:( Sorry if I don't understand you. We keep all characters until the first white-space (white-space excluded, so the white-space is the border no ?). The rest of the text is the info attributes and we trim it out (so the border is removed ?) I believe too that internal white-space should be kept. |
~~~ go( this is a comment )
~~~ Which spec supports comments in the info string? |
Yes, I believe that: ```js something
```
```js something
```
```go( something)
```
```go( s om ethi ng)
``` Should turn into: |
@ChristianMurphy None i think. It's about the user's expected result i think. Some may want to use Kramdown Attribute lists. No language has brackets in its name. So why make a error consciously ? I will code it in any case but ... :s |
Maybe it could be an option or a plugin that could be enabled. |
Ok, makes sense. Even if i think that CommonMark is wrong. See you soon people ^^ |
fbc713b
to
0b99d83
Compare
I updated the description and the PR on remark. ^^ But travis still buging 😢 remarkjs/remark#345 |
It probably started during the minor Travis CI outage. |
\o/ Thank you 😄 |
Closes GH-22. Reviewed-by: Christian Murphy <[email protected]> Reviewed-by: Titus Wormer <[email protected]>
Previously, the info string of a code block, was not parsed at all, and was stored in `lang` on `code` nodes. Now, the first “word” of the info string is stored in `lang`, whereas the rest is stored in `meta`. Related to syntax-tree/mdast#22 (PR) Closes GH-342 (issue) Closes GH-345 (PR) Reviewed-by: Titus Wormer <[email protected]> Reviewed-by: Christian Murphy <[email protected]> Co-authored-by: Titus Wormer <[email protected]>
Hi :)
It's just an update of the Code's description. The main modification is the info string tag.
Double check my english please. 🙏
💕