Syntax highlighting support for Gemini documents (SpartanJ/ecode#917).

This commit is contained in:
Martín Lucas Golini
2026-07-03 12:45:33 -03:00
parent a3d78a1217
commit fcef1c2e2c
3 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
#include <eepp/ui/doc/languages/gemini.hpp>
#include <eepp/ui/doc/syntaxdefinitionmanager.hpp>
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

View File

@@ -0,0 +1,11 @@
#ifndef EE_UI_DOC_Gemini
#define EE_UI_DOC_Gemini
#include <eepp/ui/doc/syntaxdefinition.hpp>
namespace EE { namespace UI { namespace Doc { namespace Language {
extern SyntaxDefinition& addGemini();
}}}} // namespace EE::UI::Doc::Language
#endif

View File

@@ -38,6 +38,7 @@
#include <eepp/ui/doc/languages/freebasic.hpp>
#include <eepp/ui/doc/languages/fstab.hpp>
#include <eepp/ui/doc/languages/gdscript.hpp>
#include <eepp/ui/doc/languages/gemini.hpp>
#include <eepp/ui/doc/languages/gleam.hpp>
#include <eepp/ui/doc/languages/glsl.hpp>
#include <eepp/ui/doc/languages/gn.hpp>
@@ -359,6 +360,9 @@ static void preDefinitionLangsChunk1( SyntaxDefinitionManager* sdm ) {
{ "%.gd$" },
} );
sdm->addPreDefinition(
{ "Gemini", []() -> SyntaxDefinition& { return addGemini(); }, { "%.gmi$" } } );
sdm->addPreDefinition(
{ "Gleam", []() -> SyntaxDefinition& { return addGleam(); }, { "%.gleam$" } } );