Skip to content
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

Rejecting legacy syntax prevents me from using some markdown features on code blocks #426

Open
mbarbin opened this issue Apr 25, 2023 · 0 comments

Comments

@mbarbin
Copy link

mbarbin commented Apr 25, 2023

Hi!

I'm a new (and happy!) mdx user, but I've ran into an issue. Perhaps I'm simply confused ! Here is the issue I ran into, please let me know if I am misunderstanding something about the legacy syntax error.

Issue

I'd like to use mdx to keep some code block in sync with files living in the tree, but when I try adding mdx labels on top of my code blocks, I get an error regarding mixing legacy and new syntax.

An example using showLineNumbers from https://docusaurus.io/docs/markdown-features/code-blocks#line-numbering

<!-- $MDX file=my_file.ml -->
```ocaml showLineNumbers
(* Let `dune` promote your code block here *)
```

This renders fine in my doc, but this causes a mdx error when running dune runtest

[mdx] Fatal error: File "xxxxxxxx.md", lines 116-269: invalid code block: cannot mix both block labels syntax

which I think comes from that mdx error, from lib/block.ml:

 Error [ `Msg "cannot mix both block labels syntax" ]

I am guessing that you want to lead new users towards the new syntax, while preserving backward compatibility, so I think I understand the reason for this error in general. But I wonder if this is right to reject all code block properties, simply because some of them may be targeting other markdown tools. I don't expect you'd want mdx to handle all markdown properties out there. So if I'm understanding things correctly, I would like to propose to relax the rejection rule:

Proposal

Current behavior

Complain about mixing syntax and reject md files that have code block properties if they have a <!-- $MDX --> leading header.

Desired behavior

Complain about mixing syntax for mdx specific properties. Keep the code block properties mdx doesn't know about untouched, on the assumption that they might be targeting other tools.

Detailing my understanding of both syntaxes

Legacy vs New syntax

Legacy syntax

```ocaml prop=value
```

New syntax

<!-- $MDX prop=value -->
```ocaml
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant