diff --git a/lexers/b/ballerina.go b/lexers/b/ballerina.go index 9b2665a..40aaa52 100644 --- a/lexers/b/ballerina.go +++ b/lexers/b/ballerina.go @@ -22,8 +22,8 @@ var Ballerina = internal.Register(MustNewLexer( {`(break|catch|continue|done|else|finally|foreach|forever|fork|if|lock|match|return|throw|transaction|try|while)\b`, Keyword, nil}, {`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil}, {`@[^\W\d][\w.]*`, NameDecorator, nil}, - {`(annotation|bind|but|endpoint|error|function|object|private|public|returns|service|type|var|with|worker)\b`, KeywordDeclaration, nil}, - {`(boolean|byte|decimal|float|int|json|map|nil|record|string|table|xml)\b`, KeywordType, nil}, + {`(annotation|bind|but|endpoint|error|function|object|private|public|returns|service|type|var|with|worker)\b`, KeywordDeclaration, nil}, + {`(boolean|byte|decimal|float|int|json|map|nil|record|string|table|xml)\b`, KeywordType, nil}, {`(true|false|null)\b`, KeywordConstant, nil}, {`import(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, {`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, diff --git a/lexers/g/go_test.go b/lexers/g/go_test.go index 5029822..583681e 100644 --- a/lexers/g/go_test.go +++ b/lexers/g/go_test.go @@ -1,15 +1,15 @@ package g import ( - "testing" + "testing" - "github.com/alecthomas/assert" - "github.com/alecthomas/chroma" + "github.com/alecthomas/assert" + "github.com/alecthomas/chroma" ) func TestGoHTMLTemplateIssue126(t *testing.T) { - for _, source := range []string{ - ` + for _, source := range []string{ + ` {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} {{ .Permalink }} @@ -36,15 +36,15 @@ func TestGoHTMLTemplateIssue126(t *testing.T) { `, - `{{ $headless := .Site.GetPage "page" "some-headless-bundle" }} + `{{ $headless := .Site.GetPage "page" "some-headless-bundle" }} {{ $reusablePages := $headless.Resources.Match "author*" }}

Authors

{{ range $reusablePages }}

{{ .Title }}

{{ .Content }} {{ end }}`} { - tokens, err := chroma.Tokenise(GoHTMLTemplate, nil, source) - assert.NoError(t, err) - assert.Equal(t, source, chroma.Stringify(tokens...)) - } + tokens, err := chroma.Tokenise(GoHTMLTemplate, nil, source) + assert.NoError(t, err) + assert.Equal(t, source, chroma.Stringify(tokens...)) + } } diff --git a/lexers/o/org.go b/lexers/o/org.go index 1971602..1064eaf 100644 --- a/lexers/o/org.go +++ b/lexers/o/org.go @@ -24,9 +24,9 @@ var Org = internal.Register(MustNewLexer( {`^(\*)( TODO)( .*)$`, ByGroups(GenericHeading, Error, GenericStrong), nil}, {`^(\*\*+)( TODO)( .*)$`, ByGroups(GenericSubheading, Error, Text), nil}, {`^(\*)( .+?)( :[a-zA-Z0-9_@:]+:)$`, ByGroups(GenericHeading, GenericStrong, GenericEmph), nil}, // Level 1 heading with tags - {`^(\*)( .+)$`, ByGroups(GenericHeading, GenericStrong), nil}, // // Level 1 heading with NO tags - {`^(\*\*+)( .+?)( :[a-zA-Z0-9_@:]+:)$`, ByGroups(GenericSubheading, Text, GenericEmph), nil}, // Level 2+ heading with tags - {`^(\*\*+)( .+)$`, ByGroups(GenericSubheading, Text), nil}, // Level 2+ heading with NO tags + {`^(\*)( .+)$`, ByGroups(GenericHeading, GenericStrong), nil}, // // Level 1 heading with NO tags + {`^(\*\*+)( .+?)( :[a-zA-Z0-9_@:]+:)$`, ByGroups(GenericSubheading, Text, GenericEmph), nil}, // Level 2+ heading with tags + {`^(\*\*+)( .+)$`, ByGroups(GenericSubheading, Text), nil}, // Level 2+ heading with NO tags // Checkbox lists {`^( *)([+-] )(\[[ X]\])( .+)$`, ByGroups(Text, Keyword, Keyword, UsingSelf("inline")), nil}, {`^( +)(\* )(\[[ X]\])( .+)$`, ByGroups(Text, Keyword, Keyword, UsingSelf("inline")), nil}, @@ -78,19 +78,19 @@ var Org = internal.Register(MustNewLexer( Include("inline"), }, "inline": { - {`(\s)*(\*[^ \n*][^*]+?[^ \n*]\*)((?=\W|\n|$))`, ByGroups(Text, GenericStrong, Text), nil}, // Bold - {`(\s)*(/[^/]+?/)((?=\W|\n|$))`, ByGroups(Text, GenericEmph, Text), nil}, // Italic - {`(\s)*(=[^\n=]+?=)((?=\W|\n|$))`, ByGroups(Text, NameClass, Text), nil}, // Verbatim - {`(\s)*(~[^\n~]+?~)((?=\W|\n|$))`, ByGroups(Text, NameClass, Text), nil}, // Code - {`(\s)*(\+[^+]+?\+)((?=\W|\n|$))`, ByGroups(Text, GenericDeleted, Text), nil}, // Strikethrough - {`(\s)*(_[^_]+?_)((?=\W|\n|$))`, ByGroups(Text, GenericUnderline, Text), nil}, // Underline - {`(<)([^<>]+?)(>)`, ByGroups(Text, String, Text), nil}, // - {`[{]{3}[^}]+[}]{3}`, NameBuiltin, nil}, // {{{macro(foo,1)}}} + {`(\s)*(\*[^ \n*][^*]+?[^ \n*]\*)((?=\W|\n|$))`, ByGroups(Text, GenericStrong, Text), nil}, // Bold + {`(\s)*(/[^/]+?/)((?=\W|\n|$))`, ByGroups(Text, GenericEmph, Text), nil}, // Italic + {`(\s)*(=[^\n=]+?=)((?=\W|\n|$))`, ByGroups(Text, NameClass, Text), nil}, // Verbatim + {`(\s)*(~[^\n~]+?~)((?=\W|\n|$))`, ByGroups(Text, NameClass, Text), nil}, // Code + {`(\s)*(\+[^+]+?\+)((?=\W|\n|$))`, ByGroups(Text, GenericDeleted, Text), nil}, // Strikethrough + {`(\s)*(_[^_]+?_)((?=\W|\n|$))`, ByGroups(Text, GenericUnderline, Text), nil}, // Underline + {`(<)([^<>]+?)(>)`, ByGroups(Text, String, Text), nil}, // + {`[{]{3}[^}]+[}]{3}`, NameBuiltin, nil}, // {{{macro(foo,1)}}} {`([^[])(\[fn:)([^]]+?)(\])([^]])`, ByGroups(Text, NameBuiltinPseudo, LiteralString, NameBuiltinPseudo, Text), nil}, // [fn:1] // Links {`(\[\[)([^][]+?)(\]\[)([^][]+)(\]\])`, ByGroups(Text, NameAttribute, Text, NameTag, Text), nil}, // [[link][descr]] - {`(\[\[)([^][]+?)(\]\])`, ByGroups(Text, NameAttribute, Text), nil}, // [[link]] - {`(<<)([^<>]+?)(>>)`, ByGroups(Text, NameAttribute, Text), nil}, // <> + {`(\[\[)([^][]+?)(\]\])`, ByGroups(Text, NameAttribute, Text), nil}, // [[link]] + {`(<<)([^<>]+?)(>>)`, ByGroups(Text, NameAttribute, Text), nil}, // <> // Tables {`^( *)(\|[ -].*?[ -]\|)$`, ByGroups(Text, String), nil}, // Blank lines, newlines diff --git a/lexers/s/sass.go b/lexers/s/sass.go index c84a943..6200f6a 100644 --- a/lexers/s/sass.go +++ b/lexers/s/sass.go @@ -15,13 +15,13 @@ var Sass = internal.Register(MustNewLexer( CaseInsensitive: true, }, Rules{ + // "root": { + // }, "root": { {`[ \t]*\n`, Text, nil}, - // { `[ \t]*`, ?? ??, nil }, - }, - "content": { - // { `//[^\n]*`, ?? .callback at 0x10fcaf378> ??, Push("root") }, - // { `/\*[^\n]*`, ?? .callback at 0x10fcaf400> ??, Push("root") }, + // { `[ \t]*`, ?? ??, nil }, + // { `//[^\n]*`, ?? .callback at 0x106936048> ??, Push("root") }, + // { `/\*[^\n]*`, ?? .callback at 0x1069360d0> ??, Push("root") }, {`@import`, Keyword, Push("import")}, {`@for`, Keyword, Push("for")}, {`@(debug|warn|if|while)`, Keyword, Push("value")}, @@ -112,9 +112,9 @@ var Sass = internal.Register(MustNewLexer( {`"`, LiteralStringDouble, Pop(1)}, }, "string-single": { - {`(\\.|#(?=[^\n{])|[^\n'#])+`, LiteralStringDouble, nil}, + {`(\\.|#(?=[^\n{])|[^\n'#])+`, LiteralStringSingle, nil}, {`#\{`, LiteralStringInterpol, Push("interpolation")}, - {`'`, LiteralStringDouble, Pop(1)}, + {`'`, LiteralStringSingle, Pop(1)}, }, "string-url": { {`(\\#|#(?=[^\n{])|[^\n#)])+`, LiteralStringOther, nil}, diff --git a/lexers/s/systemd.go b/lexers/s/systemd.go index e2f7e9b..6b0884e 100644 --- a/lexers/s/systemd.go +++ b/lexers/s/systemd.go @@ -7,12 +7,12 @@ import ( var SYSTEMD = internal.Register(MustNewLexer( &Config{ - Name: "SYSTEMD", + Name: "SYSTEMD", Aliases: []string{"systemd"}, Filenames: []string{"*.service"}, MimeTypes: []string{"text/plain"}, }, - Rules { + Rules{ "root": { {`\s+`, Text, nil}, {`[;#].*`, Comment, nil}, @@ -26,4 +26,3 @@ var SYSTEMD = internal.Register(MustNewLexer( }, }, )) - diff --git a/lexers/v/vb.go b/lexers/v/vb.go index 38a9185..6c4bcd1 100644 --- a/lexers/v/vb.go +++ b/lexers/v/vb.go @@ -1,75 +1,73 @@ - package v import ( - . "github.com/alecthomas/chroma" // nolint - "github.com/alecthomas/chroma/lexers/internal" + . "github.com/alecthomas/chroma" // nolint + "github.com/alecthomas/chroma/lexers/internal" ) const vbName = `[_\w][\w]*` // VB.Net lexer. var VBNet = internal.Register(MustNewLexer( - &Config{ - Name: "VB.net", - Aliases: []string{ "vb.net", "vbnet", }, - Filenames: []string{ "*.vb", "*.bas", }, - MimeTypes: []string{ "text/x-vbnet", "text/x-vba", }, - CaseInsensitive: true, - }, - Rules{ - "root": { - { `^\s*<.*?>`, NameAttribute, nil }, - { `\s+`, Text, nil }, - { `\n`, Text, nil }, - { `rem\b.*?\n`, Comment, nil }, - { `'.*?\n`, Comment, nil }, - { `#If\s.*?\sThen|#ElseIf\s.*?\sThen|#Else|#End\s+If|#Const|#ExternalSource.*?\n|#End\s+ExternalSource|#Region.*?\n|#End\s+Region|#ExternalChecksum`, CommentPreproc, nil }, - { `[(){}!#,.:]`, Punctuation, nil }, - { `Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)`, KeywordDeclaration, nil }, - { Words(`(?>=|<<|>>|:=|<=|>=|<>|[-&*/\\^+=<>\[\]]`, Operator, nil }, - { `"`, LiteralString, Push("string") }, - { `_\n`, Text, nil }, - { vbName, Name, nil }, - { `#.*?#`, LiteralDate, nil }, - { `(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?`, LiteralNumberFloat, nil }, - { `\d+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil }, - { `&H[0-9a-f]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil }, - { `&O[0-7]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil }, - }, - "string": { - { `""`, LiteralString, nil }, - { `"C?`, LiteralString, Pop(1) }, - { `[^"]+`, LiteralString, nil }, - }, - "dim": { - { vbName, NameVariable, Pop(1) }, - Default(Pop(1)), - }, - "funcname": { - { vbName, NameFunction, Pop(1) }, - }, - "classname": { - { vbName, NameClass, Pop(1) }, - }, - "namespace": { - { vbName, NameNamespace, nil }, - { `\.`, NameNamespace, nil }, - Default(Pop(1)), - }, - "end": { - { `\s+`, Text, nil }, - { `(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b`, Keyword, Pop(1) }, - Default(Pop(1)), - }, - }, + &Config{ + Name: "VB.net", + Aliases: []string{"vb.net", "vbnet"}, + Filenames: []string{"*.vb", "*.bas"}, + MimeTypes: []string{"text/x-vbnet", "text/x-vba"}, + CaseInsensitive: true, + }, + Rules{ + "root": { + {`^\s*<.*?>`, NameAttribute, nil}, + {`\s+`, Text, nil}, + {`\n`, Text, nil}, + {`rem\b.*?\n`, Comment, nil}, + {`'.*?\n`, Comment, nil}, + {`#If\s.*?\sThen|#ElseIf\s.*?\sThen|#Else|#End\s+If|#Const|#ExternalSource.*?\n|#End\s+ExternalSource|#Region.*?\n|#End\s+Region|#ExternalChecksum`, CommentPreproc, nil}, + {`[(){}!#,.:]`, Punctuation, nil}, + {`Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)`, KeywordDeclaration, nil}, + {Words(`(?>=|<<|>>|:=|<=|>=|<>|[-&*/\\^+=<>\[\]]`, Operator, nil}, + {`"`, LiteralString, Push("string")}, + {`_\n`, Text, nil}, + {vbName, Name, nil}, + {`#.*?#`, LiteralDate, nil}, + {`(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?`, LiteralNumberFloat, nil}, + {`\d+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil}, + {`&H[0-9a-f]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil}, + {`&O[0-7]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil}, + }, + "string": { + {`""`, LiteralString, nil}, + {`"C?`, LiteralString, Pop(1)}, + {`[^"]+`, LiteralString, nil}, + }, + "dim": { + {vbName, NameVariable, Pop(1)}, + Default(Pop(1)), + }, + "funcname": { + {vbName, NameFunction, Pop(1)}, + }, + "classname": { + {vbName, NameClass, Pop(1)}, + }, + "namespace": { + {vbName, NameNamespace, nil}, + {`\.`, NameNamespace, nil}, + Default(Pop(1)), + }, + "end": { + {`\s+`, Text, nil}, + {`(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b`, Keyword, Pop(1)}, + Default(Pop(1)), + }, + }, )) -