-
-
Notifications
You must be signed in to change notification settings - Fork 53
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 support for directives #57
Comments
Hi Anthony! It’s definitely a welcome addition. The reason I haven’t added support for them yet, is that I wasn’t really sure how the output should look like in HTML, or how the API would look for users to handle them and turn them to HTML. There are some ways around this: a) not emit them to HTML at all yet, then folks will have to use the AST (this doesn’t solve your use case but lets us at least work on the parsing side first) I don’t have the time to work on this the in the foreseeable future, but I’d be very excited for this feature and can help review! |
Also super interested to have this for Docusaurus 😄 Or at least faster Markdown parsing to AST. I guess there are not a lot of remark plugins that use custom extensions. |
I'm slowly getting a hang of how the state machine works and compiling the events into the AST. So we're slowly getting close to a rough PR. But I have a question about supporting attributes: https://mb21.github.io/stmd/spec.html#horizontal-rules-1
Would it make sense to also support attributes at some point in a general way that works for any other markdown elements? |
Cool! I particularly recommend keeping the JS version next to the Rust version. markdown-rs/src/construct/partial_mdx_jsx.rs Line 177 in 7340a46
They work a bit differently, but JS is easier to understand for me, and then you can directly port micromark-extension-directive to Rust: https://github.com/micromark/micromark-extension-directive/blob/5facf31692d581650ddf349852421c351af243d8/dev/lib/directive-leaf.js#L32
As far as I know “attributes” as an extension does not have the exact same style of attributes as the ones in directives? But, both are not really standardized. I like directives more than attributes: I think they solve a bigger issue than attributes do. And with directives, most of the need for attributes also disappears. I think I’d need more convincing to allow arbitrary attributes on everything, so I’d prefer sticking with directives for now, and leave that for a later discussion. As for getting code in earlier: sure, I’m open to a PR that doesn’t yet support attributes on directives! |
This sounds like a great feature! Curious how it is going? Jonesing to have a crack myself. |
Apparently ByteDance devs have implemented it in a fork: |
I have a usecase where we need to support the commonmark directives (https://github.com/remarkjs/remark-directive) and wondering if there are plans to support this, or if it's something I could contribute to.
For my usecase, markdown-rs is used as a library and it's fine to write rust code to define the directives directly, or as a fallback, even just render the directives as a web component format
<directive-name attr=attrVal>
and then the user can supply the webcomponent implementations themselves.The text was updated successfully, but these errors were encountered: