mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #78312 from Calinou/editor-add-markdown-highlighting
Add Markdown syntax highlighting to the script editor
This commit is contained in:
commit
fd75707035
2 changed files with 68 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue