language_md: some more improvements
* handle images with links * handle escaping of * and ` * support coloring a heading custom id * reverted from regex to lua patterns
This commit is contained in:
parent
c4f7380a95
commit
2ce4dbc8ef
|
@ -120,46 +120,45 @@ syntax.add {
|
||||||
{ pattern = { "```liquid", "```" }, type = "string", syntax = ".liquid" },
|
{ pattern = { "```liquid", "```" }, type = "string", syntax = ".liquid" },
|
||||||
{ pattern = { "```", "```" }, type = "string" },
|
{ pattern = { "```", "```" }, type = "string" },
|
||||||
{ pattern = { "``", "``" }, type = "string" },
|
{ pattern = { "``", "``" }, type = "string" },
|
||||||
{ pattern = { "`", "`" }, type = "string" },
|
{ pattern = { "%f[\\`]%`[%S]", "`" }, type = "string" },
|
||||||
-- strike
|
-- strike
|
||||||
{ pattern = { "~~", "~~" }, type = "keyword2" },
|
{ pattern = { "~~", "~~" }, type = "keyword2" },
|
||||||
-- highlight
|
-- highlight
|
||||||
{ pattern = { "==", "==" }, type = "literal" },
|
{ pattern = { "==", "==" }, type = "literal" },
|
||||||
-- lines
|
-- lines
|
||||||
{ regex = "^\\-{2,}\\-$", type = "comment" },
|
{ pattern = "^%-%-%-+\n", type = "comment" },
|
||||||
{ regex = "^\\*{2,}\\*$", type = "comment" },
|
{ pattern = "^%*%*%*+\n", type = "comment" },
|
||||||
{ regex = "^\\_{2,}_$", type = "comment" },
|
{ pattern = "^___+\n", type = "comment" },
|
||||||
-- bullets
|
-- bullets
|
||||||
{ regex = "^\\s*\\*\\s", type = "number" },
|
{ pattern = "^%s*%*%s", type = "number" },
|
||||||
{ regex = "^\\s*-\\s", type = "number" },
|
{ pattern = "^%s*%-%s", type = "number" },
|
||||||
{ regex = "^\\s*\\+\\s", type = "number" },
|
{ pattern = "^%s*%+%s", type = "number" },
|
||||||
-- numbered bullet
|
-- numbered bullet
|
||||||
{ regex = "^\\s*[0-9]+\\.\\s", type = "number" },
|
{ pattern = "^%s*[0-9]+%.%s", type = "number" },
|
||||||
-- blockquote
|
-- blockquote
|
||||||
{ regex = "^\\s*>{1,}\\s", type = "string" },
|
{ pattern = "^%s*>+%s", type = "string" },
|
||||||
-- bold and italic
|
-- bold and italic
|
||||||
{ pattern = { "%*%*%*", "%*%*%*" }, type = "markdown_bold_italic" },
|
{ pattern = { "%*%*%*%S", "%*%*%*" }, type = "markdown_bold_italic" },
|
||||||
{ pattern = { "%*%*", "%*%*" }, type = "markdown_bold" },
|
{ pattern = { "%*%*%S", "%*%*" }, type = "markdown_bold" },
|
||||||
-- handle edge case where asterisk can be at end of line and not close
|
-- handle edge case where asterisk can be at end of line and not close
|
||||||
{ pattern = { "%*[%S]", "%*" }, type = "markdown_italic" },
|
|
||||||
-- alternative bold italic formats
|
|
||||||
{
|
{
|
||||||
regex = "^_{3}[\\s[:punct:]A-Za-z0-9]+_{3}\\s" ,
|
pattern = { "%f[\\%*]%*[%S]", "%*%f[^%*]" },
|
||||||
type = "markdown_bold_italic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
regex = "^_{2}[\\s[:punct:]A-Za-z0-9]+_{2}\\s" ,
|
|
||||||
type = "markdown_bold"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
regex = "^_{1}[\\s[:punct:]A-Za-z0-9]+_{1}\\s" ,
|
|
||||||
type = "markdown_italic"
|
type = "markdown_italic"
|
||||||
},
|
},
|
||||||
|
-- alternative bold italic formats
|
||||||
|
{ pattern = "^___[%s%p%w]+___%s" , type = "markdown_bold_italic" },
|
||||||
|
{ pattern = "^__[%s%p%w]+__%s" , type = "markdown_bold" },
|
||||||
|
{ pattern = "^_[%s%p%w]+_%s" , type = "markdown_italic" },
|
||||||
{ pattern = { "%s___", "___%f[%s]" }, type = "markdown_bold_italic" },
|
{ pattern = { "%s___", "___%f[%s]" }, type = "markdown_bold_italic" },
|
||||||
{ pattern = { "%s__", "__%f[%s]" }, type = "markdown_bold" },
|
{ pattern = { "%s__", "__%f[%s]" }, type = "markdown_bold" },
|
||||||
{ pattern = { "%s_[%S]", "_%f[%s]" }, type = "markdown_italic" },
|
{ pattern = { "%s_[%S]", "_%f[%s]" }, type = "markdown_italic" },
|
||||||
|
-- heading with custom id
|
||||||
|
{
|
||||||
|
pattern = "^#+%s[%w%s%p]+(){()#[%w%-]+()}",
|
||||||
|
type = { "keyword", "function", "string", "function" }
|
||||||
|
},
|
||||||
-- headings
|
-- headings
|
||||||
{ regex = "^#{1,6}.+", type = "keyword" },
|
{ pattern = "^#+%s.+\n", type = "keyword" },
|
||||||
-- superscript and subscript
|
-- superscript and subscript
|
||||||
{
|
{
|
||||||
pattern = "%^()%d+()%^",
|
pattern = "%^()%d+()%^",
|
||||||
|
@ -170,13 +169,17 @@ syntax.add {
|
||||||
type = { "function", "number", "function" }
|
type = { "function", "number", "function" }
|
||||||
},
|
},
|
||||||
-- definitions
|
-- definitions
|
||||||
{ regex = "^:\\s.+", type = "function" },
|
{ pattern = "^:%s.+", type = "function" },
|
||||||
-- emoji
|
-- emoji
|
||||||
{ pattern = ":[a-zA-Z0-9_%-]+:", type = "literal" },
|
{ pattern = ":[a-zA-Z0-9_%-]+:", type = "literal" },
|
||||||
-- images and links
|
-- images and link
|
||||||
{
|
{
|
||||||
pattern = "!?%[()["..in_squares_match.."]+()%]()%(()["..in_parenthesis_match.."]+()%)",
|
pattern = "!?%[!?%[()["..in_squares_match.."]+()%]%(()["..in_parenthesis_match.."]+()%)%]%(()["..in_parenthesis_match.."]+()%)",
|
||||||
type = { "function", "string", "function", "function", "number", "function" }
|
type = { "function", "string", "function", "number", "function", "number", "function" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern = "!?%[!?%[?()["..in_squares_match.."]+()%]?%]%(()["..in_parenthesis_match.."]+()%)",
|
||||||
|
type = { "function", "string", "function", "number", "function" }
|
||||||
},
|
},
|
||||||
-- reference links
|
-- reference links
|
||||||
{
|
{
|
||||||
|
@ -184,11 +187,15 @@ syntax.add {
|
||||||
type = { "function", "string", "function", "function", "number", "function" }
|
type = { "function", "string", "function", "function", "number", "function" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern = "%[%^?()["..in_squares_match.."]+()%]: ",
|
pattern = "^%s*%[%^()["..in_squares_match.."]+()%]: ",
|
||||||
type = { "function", "number", "function" }
|
type = { "function", "number", "function" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern = "%[%^?()["..in_squares_match.."]+()%]",
|
pattern = "^%s*%[%^?()["..in_squares_match.."]+()%]:%s+.+\n",
|
||||||
|
type = { "function", "number", "function" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern = "!?%[%^?()["..in_squares_match.."]+()%]",
|
||||||
type = { "function", "number", "function" }
|
type = { "function", "number", "function" }
|
||||||
},
|
},
|
||||||
-- url's and email
|
-- url's and email
|
||||||
|
|
Loading…
Reference in New Issue