I'm trying to convert every kramdown link within a middlemanapp.
So far I've tried to prepend the Kramdown::Converter::Html module
and override the convert_a method.
module Kramdown
module Converter
module UrlConverter
def convert_a(el, indent)
"<a href=\"foo\">bar</a>"
end
end
end
end
Kramdown::Converter::Html.prepend Kramdown::Converter::UrlConverter
But for some reason, convert_a is never executed. Methods like convert_p or convert_codeblock are executed and I can change their behavior.
Kramdown 1.10.0 Middleman 4.3.5
Any ideas?
Middleman overrides
convert_a(andconvert_img) inmiddleman-core/lib/middleman-core/renderers/kramdown.rbby deriving fromKramdown::Converter::Htmland without callingsuper.Therefore by prepending to
Kramdown::Converter::Html, your method is replaced by middleman's version.You might be more successful by monkeypatching
Middleman::Renderes::MiddlemanKramdownHTMLinstead, but you'll need to be careful not to violate middleman's expectations of theconvert_amethod.