godot icon indicating copy to clipboard operation
godot copied to clipboard

Add Markdown syntax highlighting to the script editor

Open Calinou opened this issue 2 years ago • 4 comments

  • Follow-up to https://github.com/godotengine/godot/pull/77972 (can be merged independently).

There are some limitations due to how CodeEdit's highlighting works, but it's good enough for a lot of Markdown files out there already. It could be made significantly better if add_color_region() had a way to enforce the start to be at the beginning of a line, or with only leading whitespace :slightly_smiling_face:

  • This closes https://github.com/godotengine/godot-proposals/issues/1409.

Preview

Screenshot_20230616_080330

Screenshot_20230616_080339

Screenshot_20230616_080430

Screenshot_20230616_080452

Calinou avatar Jun 16 '23 06:06 Calinou

Just curious, is there any issue with 4.x compatibility on this PR? Would love to see this in an upcoming release!

yoont4 avatar Mar 19 '24 05:03 yoont4

Just curious, is there any issue with 4.x compatibility on this PR? Would love to see this in an upcoming release!

To my knowledge, there's nothing blocking this PR, but it needs a review. Since GDC is ongoing and many core contributors are there, this may take a while.

Calinou avatar Mar 19 '24 22:03 Calinou

To my knowledge, there's nothing blocking this PR, but it needs a review. Since GDC is ongoing and many core contributors are there, this may take a while.

Ah that makes total sense, thanks for the reply!

yoont4 avatar Mar 20 '24 00:03 yoont4

Is this still pending review? Would love to have this feature natively.

justin-carver avatar Oct 18 '24 07:10 justin-carver

Some valid markdown might have incorrect highlighting.

image

Text
Autolink is URL between `<` and `>`. See <https://www.example.com/> for details.

Most inline <abbr title="Hypertext Markup Language">HTML</abbr> tags are supported.

We can probably just highlight the > at the beginning of a line.

timothyqiu avatar Oct 20 '24 13:10 timothyqiu

We can probably just highlight the > at the beginning of a line.

CodeHighligher.add_color_region() doesn't have a way to make a region effective only if it starts at the beginning of the line, so this would have to be implemented first.

Calinou avatar Oct 22 '24 15:10 Calinou

Thanks!

Repiteo avatar Oct 24 '24 18:10 Repiteo

Excited for this as well!

jonathanlake avatar Nov 23 '24 21:11 jonathanlake

Is it possible to export this SyntaxHighlighter to a GDScript class? I think it would be useful for writing editor programs. Thank you!

FrostMiKu avatar Dec 07 '24 12:12 FrostMiKu

Is it possible to export this SyntaxHighlighter to a GDScript class? I think it would be useful for writing editor programs. Thank you!

I believe this is already exposed to scripting in a way that editor plugins can provide their own highlighters. We may need more documentation for this in the class reference still, or perhaps even a dedicated manual page.

Calinou avatar Dec 23 '24 17:12 Calinou