Closed talatkuyuk closed 1 year ago
Hi Talat! This can’t happen, your solution/alternatives won’t work! Feel free to try it out locally, but here’s why:
a) Using the plugins you want before remark-mdx
doesn‘t solve your problem, as it is a syntax extension, it changes how the parser works, and parsing always comes first. The other plugins are transform plugins, they work on the AST, they can’t work before parsing, because they need a parsed thing
b) if this was possible, this would break several users of MDX, remark-mdx
must come before other syntax extensions.
c) remark-fix-guillemets
can’t work with MDX, it depends on HTML nodes, MDX does not have HTML.
d) it’s by design that <
is a syntax error in these cases in MDX. You can escape them for MDX (\<\<
). remark-smartypants
will see it then.
Conceptually though, it’s really intentional that <
is unambiguous in MDX and either starts JSX or causes a parse error.
Ohh.. thank you for quick reply.
Initial checklist
Problem
In the remark eco system, some plugins process the character "<" or ">" or "<<" or ">>", in order to, for example, make guillemets turning "\<\<abc>>" to "«abc»" . link to remark-fix-guillemets (for guillemets there is need to use a
remark-textr
plugin also.)Here is another issue for
remark-smartypants
the linkIf the
format
ismd
, there is no problem. I can produce the quillemets. But, if theformat
ismdx
, the string "\<\<abc>>" cause error in the mdx files.I digged the issue. In the code of @mdx-js/mdx I found that: link
Means that,
remark-mdx
comes prior toremarkPlugins
and used just afterremark-parse
, and this causes the issue.Solution
If the
remark-mdx
would used after theremarkPlugins
in the pipeline, there would be no problem.Alternatives
In this point, if it is not convenient to use the
remark-mdx
after theremarkPlugins
, we can set another option likeremarkPluginsBeforeMdx
something like that, in order some plugins to be used beforeremark-mdx
in the pipeline. In that case the plugins likeremark-fix-guillemets
andremark-smartypants
could be useful even formdx
format markdown files.