@@ -261,6 +261,52 @@ Ref<EditorSyntaxHighlighter> EditorJSONSyntaxHighlighter::_create() const {
261261 return syntax_highlighter;
262262}
263263
264+ // //
265+
266+ void EditorMarkdownSyntaxHighlighter::_update_cache () {
267+ highlighter->set_text_edit (text_edit);
268+ highlighter->clear_keyword_colors ();
269+ highlighter->clear_member_keyword_colors ();
270+ highlighter->clear_color_regions ();
271+
272+ // Disable automatic symbolic highlights, as these don't make sense for prose.
273+ highlighter->set_symbol_color (EDITOR_GET (" text_editor/theme/highlighting/text_color" ));
274+ highlighter->set_number_color (EDITOR_GET (" text_editor/theme/highlighting/text_color" ));
275+ highlighter->set_member_variable_color (EDITOR_GET (" text_editor/theme/highlighting/text_color" ));
276+ highlighter->set_function_color (EDITOR_GET (" text_editor/theme/highlighting/text_color" ));
277+
278+ // Headings (any level).
279+ const Color function_color = EDITOR_GET (" text_editor/theme/highlighting/function_color" );
280+ highlighter->add_color_region (" #" , " " , function_color);
281+
282+ // Bold.
283+ highlighter->add_color_region (" **" , " **" , function_color);
284+ // `__bold__` syntax is not supported as color regions must begin with a symbol,
285+ // not a character that is valid in an identifier.
286+
287+ // Code (both inline code and triple-backticks code blocks).
288+ const Color code_color = EDITOR_GET (" text_editor/theme/highlighting/engine_type_color" );
289+ highlighter->add_color_region (" `" , " `" , code_color);
290+
291+ // Link (both references and inline links with URLs). The URL is not highlighted.
292+ const Color link_color = EDITOR_GET (" text_editor/theme/highlighting/keyword_color" );
293+ highlighter->add_color_region (" [" , " ]" , link_color);
294+
295+ // Quote.
296+ const Color quote_color = EDITOR_GET (" text_editor/theme/highlighting/string_color" );
297+ highlighter->add_color_region (" >" , " " , quote_color, true );
298+
299+ // HTML comment, which is also supported in Markdown.
300+ const Color comment_color = EDITOR_GET (" text_editor/theme/highlighting/comment_color" );
301+ highlighter->add_color_region (" <!--" , " -->" , comment_color);
302+ }
303+
304+ Ref<EditorSyntaxHighlighter> EditorMarkdownSyntaxHighlighter::_create () const {
305+ Ref<EditorMarkdownSyntaxHighlighter> syntax_highlighter;
306+ syntax_highlighter.instantiate ();
307+ return syntax_highlighter;
308+ }
309+
264310// //////////////////////////////////////////////////////////////////////////////
265311
266312/* ** SCRIPT EDITOR ****/
@@ -4414,6 +4460,10 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
44144460 json_syntax_highlighter.instantiate ();
44154461 register_syntax_highlighter (json_syntax_highlighter);
44164462
4463+ Ref<EditorMarkdownSyntaxHighlighter> markdown_syntax_highlighter;
4464+ markdown_syntax_highlighter.instantiate ();
4465+ register_syntax_highlighter (markdown_syntax_highlighter);
4466+
44174467 _update_online_doc ();
44184468}
44194469
0 commit comments