From fcef1c2e2ca5050f5198ce03a439b791cd4daf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 3 Jul 2026 12:45:33 -0300 Subject: [PATCH] Syntax highlighting support for Gemini documents (SpartanJ/ecode#917). --- .../src/eepp/ui/doc/languages/gemini.cpp | 91 +++++++++++++++++++ .../src/eepp/ui/doc/languages/gemini.hpp | 11 +++ .../ui/doc/languagessyntaxhighlighting.cpp | 4 + 3 files changed, 106 insertions(+) create mode 100644 src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.cpp create mode 100644 src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.hpp diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.cpp new file mode 100644 index 000000000..19b6baaf6 --- /dev/null +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.cpp @@ -0,0 +1,91 @@ +#include +#include + +namespace EE { namespace UI { namespace Doc { namespace Language { + +SyntaxDefinition& addGemini() { + + return SyntaxDefinitionManager::instance() + ->add( + + { "Gemini", + { "%.gmi$" }, + { + { { "include", "#headings" }, "normal", "", SyntaxPatternMatchType::LuaPattern }, + { { "include", "#links" }, "normal", "", SyntaxPatternMatchType::LuaPattern }, + { { "include", "#quote" }, "normal", "", SyntaxPatternMatchType::LuaPattern }, + { { "include", "#raw" }, "normal", "", SyntaxPatternMatchType::LuaPattern }, + { { "include", "#unorderedLists" }, + "normal", + "", + SyntaxPatternMatchType::LuaPattern }, + + }, + { + + }, + "", + {} + + } ) + .addRepositories( { + + { "unorderedLists", + { + { { "^(\\*)[ \t]+.+\n" }, + { "normal", "operator" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + + } }, + { "raw", + { + { { "^```.*\n", "^```.*\n" }, + { "normal" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + + } }, + { "quote", + { + { { "^(>).*$" }, + { "string", "operator" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + + } }, + { "links", + { + { { "^=>[ \t]+([^ \t]+)(?:[ \t]+(.*))?" }, + { "normal", "link", "string" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + + } }, + { "headings", + { + { { "^(#)(?:[^#].*)?\n" }, + { "keyword", "operator" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + { { "^(##)(?:[^#].*)?\n" }, + { "keyword", "operator" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + { { "^(###)(?:[^#].*)?\n" }, + { "keyword", "operator" }, + {}, + "", + SyntaxPatternMatchType::RegEx }, + + } }, + } ); +} + +}}}} // namespace EE::UI::Doc::Language diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.hpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.hpp new file mode 100644 index 000000000..ded1aeeea --- /dev/null +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/gemini.hpp @@ -0,0 +1,11 @@ +#ifndef EE_UI_DOC_Gemini +#define EE_UI_DOC_Gemini +#include + +namespace EE { namespace UI { namespace Doc { namespace Language { + +extern SyntaxDefinition& addGemini(); + +}}}} // namespace EE::UI::Doc::Language + +#endif diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp index 293f2f6a6..61cfb8b12 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languagessyntaxhighlighting.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -359,6 +360,9 @@ static void preDefinitionLangsChunk1( SyntaxDefinitionManager* sdm ) { { "%.gd$" }, } ); + sdm->addPreDefinition( + { "Gemini", []() -> SyntaxDefinition& { return addGemini(); }, { "%.gmi$" } } ); + sdm->addPreDefinition( { "Gleam", []() -> SyntaxDefinition& { return addGleam(); }, { "%.gleam$" } } );