support expressions and use them for links

This commit is contained in:
kp2pml30 2025-03-21 13:40:31 +04:00
parent b90362a6e8
commit 59b1d6c116
3 changed files with 75 additions and 26 deletions

View file

@ -106,9 +106,13 @@ class HTMLRenderer < YAMD::Renderer
@buf << "</#{name}>"
end
def code(**attrs, &blk)
tag('pre') {
tag('code', **attrs) {
def link(to, &blk)
tag('a', href: to, &blk)
end
def code(&blk)
tag('pre', class: "language-any") {
tag('code', class: "language-any") {
@buf << YAMD::Code::highlight(blk.())
}
}
@ -151,7 +155,7 @@ File.open(options[:in]) { |f|
renderer = HTMLRenderer.new
eval(code).(renderer)
renderer.instance_eval(code)
Pathname.new(options[:out]).write(renderer.finalize)
}