microsoft / microsoft/monaco-editor

[Bug] Monarch: Markdown syntax highlighting: continuation lines of list items rendered as code blocks

Open
#4,798 0 comments 1 reaction 0 assignees View on GitHub

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?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.2#XQAAAAKiAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzwauRgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKihpSJZPgox8F4oW2m8J9KFw9qZvHqyprjcG0VSNk0LOjyrVa5ikwVDlGr-NibjN81Sv0qZtUJK-NhABGuhXGrUc_yjxpWm50luejDZ7T7BSnRqO7ZbC94w-ednXHeVtLBHEPsg4q99lYm-6ylvbElZl6ZR0jjH7_6HllAwXXHEiW3mrpiyJCdj5IyePrkvuUsw0O-7ryGNyj6VaD3nx4dESXVRAnRtItkQuEuyZGs_qUA6eu8n76CB_mAZ4-zEZVya_3bUyQuFKPzVqr5w6ZAM7-veK3

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:

Image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.