Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Fixes escaped quotes

AuthorDave Jarvis <email>
Date2026-02-15 00:28:03 GMT-0800
Commite877b5beb96b829d781a2de292e4de05dfda6b83
Parent9ae57ca
render/LanguageDefinitions.php
public static function get( string $lang ): array {
$int = '(-?\b\d+(\.\d+)?\b)';
- $str = '(".*?"|\'.*?\')';
+ $str = '("(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\')';
$float = '(-?\d+(\.\d+)?([eE][+-]?\d+)?)';
$rules = [
'gradle' => [
'comment' => '/(\/\/[^\r\n]*|\/\*.*?\*\/)/ms',
- 'string_interp' => '/(".*?"|""".*?""")/',
- 'string' => '/(\'.*?\'|\'\'\'.*?\'\'\'|\/.*?\/)/',
+ 'string_interp' => '/("(?:\\\\.|[^"\\\\])*"|""".*?""")/',
+ 'string' => '/(\'(?:\\\\.|[^\'\\\\])*\'|\'\'\'.*?\'\'\'|\/.*?\/)/',
'keyword' => '/\b(def|task|apply|plugin|sourceCompatibility|targetCompatibility|repositories|dependencies|test|group|version|plugins|buildscript|allprojects|subprojects|project|ext|implementation|api|compileOnly|runtimeOnly|testImplementation|testRuntimeOnly|mavenCentral|google|jcenter|classpath)\b/',
'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\{)/',
'php' => [
'tag' => '/(<\?php|<\?|=\?>|\?>)/',
- 'string_interp' => '/(".*?")/',
- 'string' => '/(\'.*?\')/',
+ 'string_interp' => '/("(?:\\\\.|[^"\\\\])*")/',
+ 'string' => '/(\'(?:\\\\.|[^\'\\\\])*\')/',
'comment' => '/(\/\/[^\r\n]*|#[^\r\n]*|\/\*.*?\*\/)/ms',
'keyword' => '/\b(class|abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/',
'function' => '/\b([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*(?=\()/',
'variable' => '/(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/',
'number' => '/' . $int . '/',
'boolean' => '/\b(true|false|null)\b/i',
],
'bash' => [
- 'string_interp' => '/(".*?")/',
+ 'string_interp' => '/("(?:\\\\.|[^"\\\\])*")/',
'string' => '/(\'.*?\')/',
'comment' => '/(#[^\n]*)/',
],
'go' => [
- 'string' => '/(".*?"|`.*?`)/s',
+ 'string' => '/("(?:\\\\.|[^"\\\\])*"|`.*?`)/s',
'comment' => '/(\/\/[^\r\n]*|\/\*.*?\*\/)/ms',
'keyword' => '/\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go|goto|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/',
'boolean' => '/\b(true|false|nil|iota)\b/',
'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/',
'number' => '/' . $int . '/',
],
'rust' => [
- 'string' => '/(".*?"|\'.*?\')/',
+ 'string' => '/' . $str . '/',
'comment' => '/(\/\/[^\r\n]*|\/\*.*?\*\/)/ms',
'keyword' => '/\b(as|break|const|continue|crate|else|enum|extern|fn|for|if|impl|in|let|loop|match|mod|move|mut|pub|ref|return|self|Self|static|struct|super|trait|type|unsafe|use|where|while|async|await|dyn)\b/',
'boolean' => '/\b(true|false)\b/',
'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/',
'number' => '/' . $int . '/',
],
'python' => [
- 'string' => '/(\'\'\'.*?\'\'\'|""".*?"""|".*?"|\'.*?\')/s',
+ 'string' => '/(\'\'\'.*?\'\'\'|""".*?"""|"(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\')/s',
'comment' => '/(#[^\r\n]*)/m',
'keyword' => '/\b(and|as|assert|async|await|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/',
'boolean' => '/\b(False|None|True)\b/',
'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/',
'number' => '/' . $int . '/',
],
'ruby' => [
- 'string_interp' => '/(".*?")/',
- 'string' => '/(\'.*?\')/',
+ 'string_interp' => '/("(?:\\\\.|[^"\\\\])*")/',
+ 'string' => '/(\'(?:\\\\.|[^\'\\\\])*\')/',
'comment' => '/(#[^\r\n]*)/m',
'keyword' => '/\b(alias|and|begin|break|case|class|def|defined|do|else|elsif|end|ensure|for|if|in|module|next|not|or|redo|rescue|retry|return|self|super|then|undef|unless|until|when|while|yield)\b/',
'boolean' => '/\b(true|false|nil)\b/',
'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*[?!]?)\s*(?=\()/',
'variable' => '/(@[a-zA-Z_]\w*|\$[a-zA-Z_]\w*)/',
'number' => '/' . $int . '/',
],
'lua' => [
- 'string' => '/(".*?"|\'.*?\'|\[\[.*?\]\])/s',
+ 'string' => '/("(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\'|\[\[.*?\]\])/s',
'comment' => '/(--\[\[.*?\]\]|--[^\r\n]*)/ms',
'keyword' => '/\b(and|break|do|else|elseif|end|for|function|if|in|local|not|or|repeat|return|then|until|while)\b/',
'boolean' => '/\b(false|nil|true)\b/',
'function' => '/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/',
'number' => '/' . $int . '/',
],
'javascript' => [
- 'string' => '/(".*?"|\'.*?\'|`.*?`)/s',
+ 'string' => '/("(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\'|`(?:\\\\.|[^`\\\\])*`)/s',
'comment' => '/(\/\/[^\r\n]*|\/\*.*?\*\/)/ms',
'keyword' => '/\b(async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|this|throw|try|typeof|var|void|while|with|yield|let|static|enum)\b/',
'boolean' => '/\b(true|false|null|undefined)\b/',
'function' => '/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?=\()/',
'number' => '/' . $int . '/',
],
'typescript' => [
- 'string' => '/(".*?"|\'.*?\'|`.*?`)/s',
+ 'string' => '/("(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\'|`(?:\\\\.|[^`\\\\])*`)/s',
'comment' => '/(\/\/[^\r\n]*|\/\*.*?\*\/)/ms',
'keyword' => '/\b(any|as|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|module|namespace|new|of|package|private|protected|public|require|return|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/',
],
'json' => [
- 'attribute' => '/(".*?")(?=\s*:)/',
- 'string' => '/(".*?")/',
+ 'attribute' => '/("(?:\\\\.|[^"\\\\])*")(?=\s*:)/',
+ 'string' => '/("(?:\\\\.|[^"\\\\])*")/',
'boolean' => '/\b(true|false|null)\b/',
'number' => '/\b(-?\d+(\.\d+)?([eE][+-]?\d+)?)\b/',
Delta16 lines added, 16 lines removed