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