mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-05 13:05:18 +02:00
better markdown lexer
This commit is contained in:
parent
9de08fc6c8
commit
e86123a191
@ -40,7 +40,7 @@ func markdownRules() Rules {
|
||||
},
|
||||
"inline": {
|
||||
{`\\.`, Text, nil},
|
||||
{`(\s)([*_][^*_]+[*_])(\W|\n)`, ByGroups(Text, GenericEmph, Text), nil},
|
||||
{`(\s)(\*|_)((?:(?!\2).)*)(\2)((?=\W|\n))`, ByGroups(Text, GenericEmph, GenericEmph, GenericEmph, Text), nil},
|
||||
{`(\s)((\*\*|__).*?)\3((?=\W|\n))`, ByGroups(Text, GenericStrong, GenericStrong, Text), nil},
|
||||
{`(\s)(~~[^~]+~~)((?=\W|\n))`, ByGroups(Text, GenericDeleted, Text), nil},
|
||||
{"`[^`]+`", LiteralStringBacktick, nil},
|
||||
|
10
lexers/testdata/markdown.actual
vendored
10
lexers/testdata/markdown.actual
vendored
@ -4,18 +4,20 @@
|
||||
|
||||
Multiple **bold** on the **same line**.
|
||||
|
||||
Multiple _italic_ on the *same_line*.
|
||||
|
||||
## user defined function in cql
|
||||
|
||||
```javascript
|
||||
column.substring(0,num)
|
||||
column.substring(0,num)
|
||||
```
|
||||
|
||||
```cql
|
||||
CREATE FUNCTION IF NOT EXISTS cycling.left (column TEXT,num int)
|
||||
RETURNS NULL ON NULL INPUT
|
||||
RETURNS text
|
||||
LANGUAGE javascript AS $$
|
||||
column.substring(0,num)
|
||||
LANGUAGE javascript AS $$
|
||||
column.substring(0,num)
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION cycling.fLog (input double)
|
||||
@ -34,7 +36,7 @@ CREATE TABLE emp (
|
||||
last_user text
|
||||
);
|
||||
|
||||
select
|
||||
select
|
||||
$my_tag$aoeuaoeu$my_tag$ as blah
|
||||
;
|
||||
|
||||
|
12
lexers/testdata/markdown.expected
vendored
12
lexers/testdata/markdown.expected
vendored
@ -16,6 +16,10 @@
|
||||
{"type":"GenericStrong","value":"**bold**"},
|
||||
{"type":"Text","value":" on the "},
|
||||
{"type":"GenericStrong","value":"**same line**"},
|
||||
{"type":"Text","value":".\n\nMultiple "},
|
||||
{"type":"GenericEmph","value":"_italic_"},
|
||||
{"type":"Text","value":" on the "},
|
||||
{"type":"GenericEmph","value":"*same_line*"},
|
||||
{"type":"Text","value":".\n\n"},
|
||||
{"type":"GenericSubheading","value":"## user defined function in cql\n"},
|
||||
{"type":"Text","value":"\n"},
|
||||
@ -29,7 +33,7 @@
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"NameOther","value":"num"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":" \n"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"LiteralString","value":"```"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"LiteralString","value":"```cql\n"},
|
||||
@ -78,7 +82,7 @@
|
||||
{"type":"Keyword","value":"AS"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralStringHeredoc","value":"$$"},
|
||||
{"type":"Text","value":" \n "},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"NameOther","value":"column"},
|
||||
{"type":"Punctuation","value":"."},
|
||||
{"type":"NameOther","value":"substring"},
|
||||
@ -87,7 +91,7 @@
|
||||
{"type":"Punctuation","value":","},
|
||||
{"type":"NameOther","value":"num"},
|
||||
{"type":"Punctuation","value":")"},
|
||||
{"type":"Text","value":" \n"},
|
||||
{"type":"Text","value":"\n"},
|
||||
{"type":"LiteralStringHeredoc","value":"$$"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n\n"},
|
||||
@ -191,7 +195,7 @@
|
||||
{"type":"Punctuation","value":");"},
|
||||
{"type":"Text","value":"\n\n"},
|
||||
{"type":"Keyword","value":"select"},
|
||||
{"type":"Text","value":" \n "},
|
||||
{"type":"Text","value":"\n "},
|
||||
{"type":"LiteralStringHeredoc","value":"$my_tag$aoeuaoeu$my_tag$"},
|
||||
{"type":"Text","value":" "},
|
||||
{"type":"Keyword","value":"as"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user