Comments (13)
Hi \o
I just didn't implement it. It a new syntax and it need a complete parser for fenced code.
However i should be able to implement that syntax :
```html
<p>Hello !</p>
```
{ style="..." }
Which is more consistent with the syntax of the other non-inline (block) elements.
About the first syntax, someone should talk with the creator of remark about that.
from remark-attr.
Are you saying you think the fenced code syntax should be:
```html
<p>Hello !</p>
```
{ style="..." }
vs:
```html { style="..." }
<p>Hello !</p>
```
Any strong reason for one over the other?
I currently using a custom remark plugin to handle:
```html 'class="..."'
<p>Hello !</p>
```
I'd prefer to use remark-attr
.
from remark-attr.
Are you saying you think the fenced code syntax should be:
Yes, you got my point :)
Any strong reason for one over the other?
Strong, maybe not but at least there are reasons.
With markdown, there are 2 types of elements. Block and span. This plugin add a bracket custom markdown attributes syntax which is placed at the end of the original syntax. On the same line for span element and to the next line for block element.
# Here a title
{ type="block" }
*Please, chance it.*{ author="malcolm" type="span" }
Another reason is that i don't know if the syntax :
~~~lang { attr="val" }
Is in use. I know that Pandoc use something similar, but i far as i know it is something like that :
```{ lang="c" attr="val"}
Pandoc is also compatible with :
~~~lang
But can we mix it ? I don't know.
And finally, they is that info string syntax.
~~~lang attr=val attr2=val
info string is used in Github Flavored Markdown and CommonMark so i think it's a common syntax. However, remark doesn't support it at the moment. Maybe i should make a PR about it.
Mixing info string syntax with the Pandoc one will look ugly as :
```lang attr=val attr2='val' { attr='otherVal' attr3=yes }
And I preferred not to.
That's my point. I'm interested in yours. :)
Edit: Bad english π€¦ββοΈ
from remark-attr.
Hmm... a couple of comments:
I would prefer the attrs be after the language only for readability.
~~~lang { attr="val" }
The pandoc syntax is not very useful since it will interfere with syntax editors.
It looks like the info string in GFM is pretty much only used for the language.
from remark-attr.
Hummm ...
Ok. I put it on my todo-list. I don't guaranty anything, but i will try something.
from remark-attr.
I'm willing and able to contribute... as long as we have a good idea of the syntax.
from remark-attr.
π
The syntax ?
~~~ lang { attr="val" }
The one you talked about.
Where '{ attr="val" }' is a info string, that's the trick, the parsing of the info string can be made by md-attr-parser. As it's coded, it will handle both 'attr="val"'
and '{ attr="val"}'
, which is pretty cool.
So info string should be support by remark first. I made a issue about that : remarkjs/remark#342, it's easy to implement by it had to be merged first.
So both of the syntax will be supported by the plugin :
~~~haskell { start_line=2 }
f x = 2*x
~~~
and
~~~haskell start_line=2
f x = 2*x
~~~
And a fallback support of the suffixed custom attributes for block. Kind of like kramdown does.
It's a short commit to that plugin.
The hardest thing will be the configuration.
What do you think ?
from remark-attr.
I'm really not sure what support is needed from remark itself. Currently for fenced code like ~~~haskell { start_line=2 }
the intire string after the tripple tick is interpreted as the language (so here node.lang = "haskell { start_line=2 }"
. I belive we would need nothing more than to extract the attr portion from the language string (aka info string). Am I oversimplifying this? I'm sure you have been working with remark for a lot longer than me.
from remark-attr.
Hahah, that's true. But it look like a bug to me.
In fact, now, fenced code like ~~~haskell { start_line=2 }
will break others plugins like remark-highlight.js. So we can't exploit the fact that remark missparse lang
. But as we can see, implement a info string support to remark will be easy.
from remark-attr.
I could be wrong but appears to me that in this example ~~~haskell { start_line=2 }
the info string is "haskell { start_line=2 }"
and remark is placing the entire info string in lang
property (maybe poorly named in that case). So the bug is in remark-highlight.js
that doesn't correctly parse the info string.
From the GFM spec:
The first word of the info string is typically used to specify the language of the code sample, and rendered in the class attribute of the code tag.
from remark-attr.
Oh !
You have definitively right ! ... By the end of the WE ... π
Thanks :)
from remark-attr.
Looking at the CommonMark spec and the CommonMark demo also leads me to believe that the entire string is the info string:
Notice that the generated AST is <code_block info="this is all info string">
from remark-attr.
Humm, now they is some new tests about this feature. Also, the upcoming version of remark is already supported. Only the syntax :
~~~lang { attr="val" }
is supported. Not this one :
~~~{Β land attr="val" }
~~~
Nore this one :
~~~
~~~
{lang attr="qsdqsd"}
~~~~
The reason to this is to not break compatibility with others markdown engine that only support the `lang` attribute.
from remark-attr.
Related Issues (18)
- Remove undefined values from hProperties HOT 1
- There is a bug HOT 4
- key/class/id support HOT 2
- classes? HOT 1
- [email protected] npm package missing dist/index.js file HOT 2
- Attribute for <p> / paragraph? HOT 18
- Support attributes in the same line as an ATX heading? HOT 5
- Support spans with attributes? HOT 1
- Support for custom data attributes HOT 5
- Stop looking for attrs in the fenced code HOT 3
- Support for linkReference HOT 4
- Are image elements supported? HOT 8
- Support angle-bracket links HOT 2
- Tags not added on images with Docusaurus HOT 4
- remark@next (13) HOT 10
- ATX-style cannot specify attributes if the header has inline syntax HOT 1
- 'Missing parser to attach `remark-attr` [link] (to) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remark-attr.