From 4a6effbc24822c3a9109b137aacf54ac75a2cced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 9 Mar 2025 13:58:11 -0300 Subject: [PATCH] Fix JSON to C++ language converted when using regexs. --- src/eepp/ui/doc/syntaxdefinitionmanager.cpp | 14 ++++++++++---- .../src/eepp/ui/doc/languages/svelte.cpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp index c6917d85f..4ecd79cf0 100644 --- a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp +++ b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp @@ -159,7 +159,8 @@ static std::string str( std::string s, const std::string& prepend = "", } static std::string join( std::vector const& vec, bool createCont = true, - bool allowReduce = false, std::string delim = ", " ) { + bool allowReduce = false, bool setType = false, + std::string delim = ", " ) { if ( vec.empty() ) return "{}"; if ( vec.size() == 1 && allowReduce ) @@ -167,7 +168,9 @@ static std::string join( std::vector const& vec, bool createCont = std::string accum = std::accumulate( vec.begin() + 1, vec.end(), str( vec[0] ), [&delim]( const std::string& a, const std::string& b ) { return a + delim + str( b ); } ); - return createCont ? "{ " + accum + " }" : accum; + return createCont + ? ( std::string( setType ? "std::vector" : "" ) + "{ " + accum + " }" ) + : accum; } static std::string funcName( std::string name ) { @@ -202,10 +205,13 @@ namespace EE { namespace UI { namespace Doc { namespace Language { // patterns buf += "{\n"; for ( const auto& pattern : def.getPatterns() ) { - buf += "{ " + join( pattern.patterns ) + ", " + join( pattern.typesNames, true, true ) + + buf += "{ " + join( pattern.patterns ) + ", " + + join( pattern.typesNames, true, true, pattern.isRegEx ) + str( pattern.syntax, ", ", "", false ); - if ( pattern.isRegEx ) + if ( pattern.isRegEx && pattern.syntax.empty() ) buf += ", \"\", true"; + else if ( pattern.isRegEx ) + buf += ", true"; buf += " },\n"; } buf += "\n},\n"; diff --git a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/svelte.cpp b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/svelte.cpp index 6ada658cb..e5f687a5c 100644 --- a/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/svelte.cpp +++ b/src/modules/languages-syntax-highlighting/src/eepp/ui/doc/languages/svelte.cpp @@ -41,7 +41,7 @@ void addSvelte() { "", true }, { { "{(#if|#each|#await|#key)", "}", "\\" }, - { "keyword", "keyword2", "normal" }, + std::vector{ "keyword", "keyword2", "normal" }, "JavaScript", true }, { { "{", "}", "\\" }, "keyword", "JavaScript" },