On Fri, May 22, 2020 at 4:00 AM Martin Nilsson (Coppermist) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
While I'm indifferent to markdown itself, my problem with the markdown implementation in Pike is that it was implemented as an application with no programmatic way of controlling its behavior. That's why we moved it into the Tools module. A proper markdown module should be easy to extened and control from code.
Okay. Here's a proposal then.
I'll go through the Markdown module and give it a bunch of hooks intended for subclasses, and also unprotect Parser and Lexer. Then anyone can do something like:
class Renderer { inherit Tools.Markdown.Renderer; string table(string header, string body, mapping attrs) { return ::table(header, body, attrs | (["border": "1"])); } }
as an easy way to make a small tweak to the behaviour. And yes, part of this would be that every HTML tag emitter would take an attrs mapping, which would then mean that my original proposal (having a specially-formatted block at the end of a paragraph) would become a simple job of subclassing the parser.
(Oh, and I'd add a Parser entry to the options mapping, to make it easier and more logical to override. Same as Renderer currently is.)
How does that sound?
ChrisA
pike-devel@lists.lysator.liu.se