On 2018-04-25 12:28 -0700
j...@saturnflyer.com wrote:
> Is there a way to hook into the fenced code block processing to
> change instances of a single space character to " "?
> I want to end each line of code with a break element as well.
If you want to only change code blocks created by the fenced code
blocks parser, you would need to derive a parser class from the
standard kramdown parser and override the #parse_codeblock_fenced
method.
However, you could also parse the document and then modify the abstract
syntax tree before outputting to HTML, see the [TOC converter][1] for a
possibility.
Finally, the third option would be to derive a new converter from the
HTML converter and override the #convert_codeblock method by
pre-processing `el.value` (the contents of the codeblock) with what you
need.
Best regards,
Thomas
[1]:
https://github.com/gettalong/kramdown/blob/master/lib/kramdown/converter/toc.rb