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

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

Open
2 tasks
kareldonk opened this issue Jan 6, 2025 · 0 comments

Comments

@kareldonk
Copy link

kareldonk commented Jan 6, 2025

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: #2489

Expected Behavior

No response

Additional Context

monaco-editor version: 0.52.2

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