Closed floatrx closed 6 months ago
My guess is that you need to configure the codeMirrorPlugin to support code blocks without any language specified, by passing a '': 'Text'
to the codeBlockLanguages. Give it a try.
My guess is that you need to configure the codeMirrorPlugin to support code blocks without any language specified, by passing a
'': 'Text'
to the codeBlockLanguages. Give it a try.
I don't use the codeMirrorPlugin, and it's unnecessary for my purposes. Markdown inherently supports code blocks without the requirement to specify a language.
This bug was also reproduced in the official live demo
This issue is not critical but it would be nice to have it fixed.
Perhaps my response was not clear. The editor supports code blocks without a language, but you need to configure it so that it actually knows what kind of editor to associate with such a code block. I suggested the codeMirror one, but you can also use whatever you wish, the docs include an example with a text area.
I have encountered the same error as you, and need to configure all the code block languages you use in markdown to codeMirrorPlugin
@wp0403 Helps, but we should explicitly provide an empty string ('')
const codeBlockLanguages = ['', ...]; // <- here
...
codeMirrorPlugin({
codeBlockLanguages: codeBlockLanguages.reduce((acc, language) => {
acc[language] = language;
return acc;
}, {}),
}),```
My guess is that you need to configure the codeMirrorPlugin to support code blocks without any language specified, by passing a
'': 'Text'
to the codeBlockLanguages. Give it a try.
This would be great to have in the example in the docs.
Description: When using the MDXEditor in source mode and attempting to insert a code block using triple backticks (```), the editor fails to parse the markdown structure, resulting in a parsing error. This issue prevents users from adding code snippets to their markdown documents directly in the source mode.
Error Message:
Parsing of the following markdown structure failed: {"type":"code","name":"N/A"}. Steps to Reproduce:
Steps 2 reproduce
Expected Behavior: The editor should correctly parse the code block enclosed in triple backticks, allowing the user to insert code snippets into their markdown document without encountering a parsing error.
Actual Behavior: The editor displays a parsing error when attempting to insert a code block using triple backticks, preventing the user from successfully adding code snippets in source mode.