diff options
Diffstat (limited to 'lexlua/markdown.lua')
| -rw-r--r-- | lexlua/markdown.lua | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lexlua/markdown.lua b/lexlua/markdown.lua index fbedb2418..733c39fec 100644 --- a/lexlua/markdown.lua +++ b/lexlua/markdown.lua @@ -12,10 +12,11 @@ local function h(n) return token('h' .. n, lexer.to_eol(lexer.starts_line(string.rep('#', n)))) end lex:add_rule('header', h(6) + h(5) + h(4) + h(3) + h(2) + h(1)) +local font_size = + tonumber(lexer.property_expanded['style.default']:match('size:(%d+)')) or 10 local function add_header_style(n) - local font_size = lexer.property_int['fontsize'] > 0 and - lexer.property_int['fontsize'] or 10 - lex:add_style('h' .. n, 'fore:$(color.red),size:' .. (font_size + (6 - n))) + lex:add_style( + 'h' .. n, {fore = lexer.colors.red, size = (font_size + (6 - n))}) end for i = 1, 6 do add_header_style(i) end @@ -42,7 +43,7 @@ local code_inline = lpeg.Cmt(lpeg.C(P('`')^1), function(input, index, bt) return (e or #input) + 1 end) lex:add_rule('block_code', token('code', code_line + code_block + code_inline)) -lex:add_style('code', lexer.STYLE_EMBEDDED .. ',eolfilled') +lex:add_style('code', lexer.STYLE_EMBEDDED .. {eolfilled = true}) lex:add_rule('hr', token('hr', lpeg.Cmt( lexer.starts_line(S(' \t')^0 * lpeg.C(S('*-_'))), function(input, index, c) @@ -50,7 +51,7 @@ lex:add_rule('hr', token('hr', lpeg.Cmt( if line:find('[^' .. c .. ']') or #line < 2 then return nil end return (select(2, input:find('\r?\n', index)) or #input) + 1 end))) -lex:add_style('hr', 'back:$(color.black),eolfilled') +lex:add_style('hr', {back = lexer.colors.black, eolfilled = true}) -- Whitespace. local ws = token(lexer.WHITESPACE, S(' \t')^1 + S('\v\r\n')^1) @@ -66,7 +67,7 @@ local ref_link_title = token(lexer.STRING, lexer.range('"', true, false) + lex:add_rule('link_label', ref_link_label * ws * ref_link_url * (ws * ref_link_title)^-1) lex:add_style('link_label', lexer.STYLE_LABEL) -lex:add_style('link_url', 'underlined') +lex:add_style('link_url', {underlined = true}) local link_label = P('!')^-1 * lexer.range('[', ']', true) local link_target = P('(') * (lexer.any - S(') \t'))^0 * @@ -75,7 +76,7 @@ local link_ref = S(' \t')^0 * lexer.range('[', ']', true) local link_url = 'http' * P('s')^-1 * '://' * (lexer.any - lexer.space)^1 lex:add_rule('link', token('link', link_label * (link_target + link_ref) + link_url)) -lex:add_style('link', 'underlined') +lex:add_style('link', {underlined = true}) local punct_space = lexer.punct + lexer.space @@ -95,12 +96,12 @@ end lex:add_rule('strong', token('strong', flanked_range('**') + (lpeg.B(punct_space) + #lexer.starts_line('_')) * flanked_range('__', true) * #(punct_space + -1))) -lex:add_style('strong', 'bold') +lex:add_style('strong', {bold = true}) lex:add_rule('em', token('em', flanked_range('*') + (lpeg.B(punct_space) + #lexer.starts_line('_')) * flanked_range('_', true) * #(punct_space + -1))) -lex:add_style('em', 'italics') +lex:add_style('em', {italics = true}) -- Embedded HTML. local html = lexer.load('html') |
