microsoft / microsoft/monaco-editor
[Bug] Monarch: Markdown syntax highlighting: continuation lines of list items rendered as code blocks
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
Reproduction Steps
No response
Actual (Problematic) Behavior
There is an issue with syntax highlighting in case of Markdown files:
Continuation lines of list elements are highlighted as if they were code blocks, if the indentation is 4 spaces (3 spaces between the - and the text), or one tab:
List:
- item1
- item2
continuation of item2
paragraph, still part of the list item2
Not part of list.
In the Language Editor within the Monaco-Editor of the Monarch documention this is displayed as:
Monarch's language syntax definition for Markdown contains a rule for code blocks that renders indented lines (4 spaces or a tab) as string:
[
// list (starting with * or number)
[/^\s*([\*\-+:]|\d+\.)\s/, 'keyword'],
// code block (4 spaces indent)
[/^(\t|[ ]{4})[^ ].*$/, 'string']
]
This also explains why the effect is visible only if the indentation of the continuation lines is exactly 4 spaces or 1 tab, not if it is e.g. 3 spaces. Perhaps the grammar for lists would need to be more complex.
Lists can also contain sub elements such as paragraphs, tables, code blocks and nested lists etc.
Relates to: https://github.com/microsoft/monaco-editor/issues/2489
Expected Behavior
No response
Additional Context
monaco-editor version: 0.52.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Monarch Markdown syntax definition and reproduce the example in the linked Monaco Editor Playground. Review the list and indented code-block rules shown in the issue, then verify that continuation lines remain part of list items without changing the highlighting of genuine code blocks or unrelated indentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100