add code blocks + copy
This commit is contained in:
@ -44,7 +44,9 @@ function babycode.to_html(s, escape_html)
|
||||
|
||||
-- replace code block placeholders back with their original contents
|
||||
text = text:gsub("\1CODE:(%d+)\1", function(n)
|
||||
return "<pre><code>"..code_blocks[tonumber(n)].."</code></pre>"
|
||||
local code = code_blocks[tonumber(n)]
|
||||
local button = ("<button type=button class=\"copy-code\" value=\"%s\">Copy</button>"):format(code)
|
||||
return "<pre><span class=\"copy-code-container\">" .. button .. "</span><code>"..code.."</code></pre>"
|
||||
end)
|
||||
|
||||
return text
|
||||
|
Reference in New Issue
Block a user