~martanne/vis

0158a398142a62b96c6f12139c914614bd90067d — Marc André Tanner 11 months ago 3d9986c
lexers/markdown: support <https://foo.bar> links in markdown

Requires the HTML lexer to ignore namespaced tags, otherwise <...>
Markdown links would be recognized as HTML tags. HTML doesn't seem to
support namespaced elements like XML does, so this should be okay.

Upstream commit 553eb706c233d7088c4cb2bbd589cbf9eb0f1e72.
2 files changed, 3 insertions(+), 2 deletions(-)

M lua/lexers/html.lua
M lua/lexers/markdown.lua
M lua/lexers/html.lua => lua/lexers/html.lua +1 -1
@@ 37,7 37,7 @@ local paired_element = token('element', '<' * P('/')^-1 * word_match([[
local known_element = single_element + paired_element
local unknown_element = token('unknown_element', '<' * P('/')^-1 *
  (lexer.alnum + '-')^1)
local element = known_element + unknown_element
local element = (known_element + unknown_element) * -P(':')
lex:add_rule('element', element)
lex:add_style('single_element', lexer.styles.keyword)
lex:add_style('element', lexer.styles.keyword)

M lua/lexers/markdown.lua => lua/lexers/markdown.lua +2 -1
@@ 73,7 73,8 @@ local link_label = P('!')^-1 * lexer.range('[', ']', true)
local link_target = '(' * (lexer.any - S(') \t'))^0 *
  (S(' \t')^1 * lexer.range('"', false, false))^-1 * ')'
local link_ref = S(' \t')^0 * lexer.range('[', ']', true)
local link_url = 'http' * P('s')^-1 * '://' * (lexer.any - lexer.space)^1
local link_url = 'http' * P('s')^-1 * '://' * (lexer.any - lexer.space)^1 +
  '<' * lexer.alpha^2 * ':' * (lexer.any - lexer.space - '>')^1 * '>'
lex:add_rule('link', token('link', link_label * (link_target + link_ref) +
  link_url))
lex:add_style('link', {underlined = true})