mirror of
https://github.com/alecthomas/chroma.git
synced 2025-11-27 22:38:42 +02:00
@@ -2,11 +2,12 @@ package m
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/alecthomas/chroma" // nolint
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/h"
|
||||||
"github.com/alecthomas/chroma/lexers/internal"
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Markdown lexer.
|
// Markdown lexer.
|
||||||
var Markdown = internal.Register(MustNewLexer(
|
var Markdown = internal.Register(DelegatingLexer(h.HTML, MustNewLexer(
|
||||||
&Config{
|
&Config{
|
||||||
Name: "markdown",
|
Name: "markdown",
|
||||||
Aliases: []string{"md", "mkd"},
|
Aliases: []string{"md", "mkd"},
|
||||||
@@ -40,8 +41,8 @@ var Markdown = internal.Register(MustNewLexer(
|
|||||||
{"`[^`]+`", LiteralStringBacktick, nil},
|
{"`[^`]+`", LiteralStringBacktick, nil},
|
||||||
{`[@#][\w/:]+`, NameEntity, nil},
|
{`[@#][\w/:]+`, NameEntity, nil},
|
||||||
{`(!?\[)([^]]+)(\])(\()([^)]+)(\))`, ByGroups(Text, NameTag, Text, Text, NameAttribute, Text), nil},
|
{`(!?\[)([^]]+)(\])(\()([^)]+)(\))`, ByGroups(Text, NameTag, Text, Text, NameAttribute, Text), nil},
|
||||||
{`[^\\\s]+`, Text, nil},
|
{`[^\\\s]+`, Other, nil},
|
||||||
{`.|\n`, Text, nil},
|
{`.|\n`, Other, nil},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
))
|
)))
|
||||||
|
|||||||
2
lexers/testdata/markdown.actual
vendored
2
lexers/testdata/markdown.actual
vendored
@@ -1,5 +1,7 @@
|
|||||||
# about
|
# about
|
||||||
|
|
||||||
|
<div class="html">HTML</div>
|
||||||
|
|
||||||
Multiple **bold** on the **same line**.
|
Multiple **bold** on the **same line**.
|
||||||
|
|
||||||
## user defined function in cql
|
## user defined function in cql
|
||||||
|
|||||||
14
lexers/testdata/markdown.expected
vendored
14
lexers/testdata/markdown.expected
vendored
@@ -1,6 +1,18 @@
|
|||||||
[
|
[
|
||||||
{"type":"GenericHeading","value":"# about\n"},
|
{"type":"GenericHeading","value":"# about\n"},
|
||||||
{"type":"Text","value":"\nMultiple "},
|
{"type":"Text","value":"\n"},
|
||||||
|
{"type":"Punctuation","value":"\u003c"},
|
||||||
|
{"type":"NameTag","value":"div"},
|
||||||
|
{"type":"Text","value":" "},
|
||||||
|
{"type":"NameAttribute","value":"class"},
|
||||||
|
{"type":"Operator","value":"="},
|
||||||
|
{"type":"LiteralString","value":"\"html\""},
|
||||||
|
{"type":"Punctuation","value":"\u003e"},
|
||||||
|
{"type":"Text","value":"HTML"},
|
||||||
|
{"type":"Punctuation","value":"\u003c/"},
|
||||||
|
{"type":"NameTag","value":"div"},
|
||||||
|
{"type":"Punctuation","value":"\u003e"},
|
||||||
|
{"type":"Text","value":"\n\nMultiple "},
|
||||||
{"type":"GenericStrong","value":"**bold**"},
|
{"type":"GenericStrong","value":"**bold**"},
|
||||||
{"type":"Text","value":" on the "},
|
{"type":"Text","value":" on the "},
|
||||||
{"type":"GenericStrong","value":"**same line**"},
|
{"type":"GenericStrong","value":"**same line**"},
|
||||||
|
|||||||
Reference in New Issue
Block a user