summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 7e0331d15c..96a9dd7a80 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -261,6 +261,52 @@ Ref<EditorSyntaxHighlighter> EditorJSONSyntaxHighlighter::_create() const {
return syntax_highlighter;
}
+////
+
+void EditorMarkdownSyntaxHighlighter::_update_cache() {
+ highlighter->set_text_edit(text_edit);
+ highlighter->clear_keyword_colors();
+ highlighter->clear_member_keyword_colors();
+ highlighter->clear_color_regions();
+
+ // Disable automatic symbolic highlights, as these don't make sense for prose.
+ highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ highlighter->set_member_variable_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ highlighter->set_function_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+
+ // Headings (any level).
+ const Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
+ highlighter->add_color_region("#", "", function_color);
+
+ // Bold.
+ highlighter->add_color_region("**", "**", function_color);
+ // `__bold__` syntax is not supported as color regions must begin with a symbol,
+ // not a character that is valid in an identifier.
+
+ // Code (both inline code and triple-backticks code blocks).
+ const Color code_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
+ highlighter->add_color_region("`", "`", code_color);
+
+ // Link (both references and inline links with URLs). The URL is not highlighted.
+ const Color link_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ highlighter->add_color_region("[", "]", link_color);
+
+ // Quote.
+ const Color quote_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ highlighter->add_color_region(">", "", quote_color, true);
+
+ // HTML comment, which is also supported in Markdown.
+ const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ highlighter->add_color_region("<!--", "-->", comment_color);
+}
+
+Ref<EditorSyntaxHighlighter> EditorMarkdownSyntaxHighlighter::_create() const {
+ Ref<EditorMarkdownSyntaxHighlighter> syntax_highlighter;
+ syntax_highlighter.instantiate();
+ return syntax_highlighter;
+}
+
////////////////////////////////////////////////////////////////////////////////
/*** SCRIPT EDITOR ****/
@@ -4414,6 +4460,10 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
json_syntax_highlighter.instantiate();
register_syntax_highlighter(json_syntax_highlighter);
+ Ref<EditorMarkdownSyntaxHighlighter> markdown_syntax_highlighter;
+ markdown_syntax_highlighter.instantiate();
+ register_syntax_highlighter(markdown_syntax_highlighter);
+
_update_online_doc();
}