You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for this project and great ecosystem! I just started to learn how to use remark and retype and can't figure out how can I differentiate inline code vs block code.
My aim is to override these components with my own so I try to do it this way:
and of course, code affects both to inline and block code sections while I need to set separate components for them.
So could you point me the right way to do it?
Hmm, I dunno. “Block” and “Inline” are CSS concepts. In markdown, you have them too, but they refer more to <code> in <pre> and <code> in other stuff...
One thing I may have: check in the pre handler if there’s one node, and if it’s a code?
Otherwise: What’s your expected output? What are you passing in?
this works at least when I use hilight.js because it inserts a lot of <span/> inside. In general I want to use separate <ReacComponent /> to handle "block" code and add some styles for "inline" code. If I could reach parent of component it would help? Some kind of this:
Maybe it's not a right place to do it? Possible I need to handle this cases in remark level? I tried to dig into remark-vdom in order to pass some props/class names/something but without success yet
So, the type of token is different (inlineCode and code). To know which the <code> was from inline code or fenced code, I think they should be processed before converting MDAST into HAST. I guess you can write MDAST transform plugin and insert your own mark like class property at the node in order to distinguish inline/fenced code.
I'm expecting that props will contain a href field with value of my link. But props are always empty!
My guess is that it's because of sanitization?
But I can't find a place where I could disable this option ...or I do something wrong?
Activity
wooorm commentedon Aug 20, 2017
Hmm, I dunno. “Block” and “Inline” are CSS concepts. In markdown, you have them too, but they refer more to
<code>in<pre>and<code>in other stuff...One thing I may have: check in the
prehandler if there’s one node, and if it’s acode?Otherwise: What’s your expected output? What are you passing in?
usulpro commentedon Aug 20, 2017
By inline I mean that goes in a single backquote like this:
just stringAnd by block, I mean the triple backquoted code e.g:
At this moment I found a workaround like this:
this works at least when I use hilight.js because it inserts a lot of
<span/>inside. In general I want to use separate<ReacComponent />to handle "block" code and add some styles for "inline" code. If I could reachparentof component it would help? Some kind of this:Maybe it's not a right place to do it? Possible I need to handle this cases in
remarklevel? I tried to dig into remark-vdom in order to pass some props/class names/something but without success yetrhysd commentedon Aug 21, 2017
I may miss the point...
I dug into parser code.
Inline code: https://github.com/wooorm/remark/blob/master/packages/remark-parse/lib/tokenize/code-inline.js
Fenced (Block) code: https://github.com/wooorm/remark/blob/master/packages/remark-parse/lib/tokenize/code-fenced.js
So, the type of token is different (
inlineCodeandcode). To know which the<code>was from inline code or fenced code, I think they should be processed before converting MDAST into HAST. I guess you can write MDAST transform plugin and insert your own mark likeclassproperty at the node in order to distinguish inline/fenced code.wooorm commentedon Aug 21, 2017
@rhysd That could work too!
usulpro commentedon Aug 21, 2017
@rhysd Thank you for pointing me that, I'll start to dig in this direction.
May I ask you one more question?
My chain looks this way:
and for example, I try to override
<a href=... />:I'm expecting that
propswill contain ahreffield with value of my link. Butpropsare always empty!My guess is that it's because of sanitization?
But I can't find a place where I could disable this option ...or I do something wrong?
[-]How to override inline/block code[/-][+]How to override inline/fenced code[/+]usulpro commentedon Aug 21, 2017
Sorry, my fault!
components overriding function should look this way:
in this case
propsforacontainshrefandpropsforcodecontainsclassName='language-js'(only if you specify one in markdown)