Cool stuff.
Would’t it be nice to have a Delimiter Attribute in the Hook. So we could distinguish between different handling for these passthrough.
\[ my block \]
$$ math block $$
And then in the render-passthrough-block.html
{{ if eq .Delimiter "$$" }}
{{ render Math }}
{{ else }}
{{ render My }}
{{ end }}
Or have I missed this possibility somewhere?
The docs tell:
Inner
(
string
) The inner content of the passthrough element, excluding the delimiters.
No, but I don’t think having the delimiters (a config thing) being an identifier in your layout files is a great way of doing it.
When @jmooring first came up with the idea of the passthrough extension I knew that at some point, someone would ask about using them for “something other than math”, and that we would need multiple instances of them. But that needs to start with the configuration (it supports 1 only), and then we need to think about how to handle the templates, but I don’t think the .Delimiter
is the right discriminator.
Cool you already thought about and I totally agree, that using the literal string is odd.
There are already different delimiters for a block passthrough available. . It’s just handled by the same hook.
block = [['\[', '\]'], ['$$', '$$']]
Indeed. Maybe something like:
block:
- math:
- [ \[, \]
- $$, $$
- other:
- #*, *#
Inline...
And pass that to the goldmark … or different hooks (block-math.html), or…
I guess be not that straightforward and some effort.
Might be something for the future… :slight_smile
Well, I imagined we could just allow multiple passthrough configs, e.g.
[markup.goldmark.extensions.passthrough.math]
enable = false
[markup.goldmark.extensions.passthrough.math.delimiters]
block = []
inline = []
[markup.goldmark.extensions.passthrough.foo]
enable = false
[markup.goldmark.extensions.passthrough.foo.delimiters]
block = []
inline = []
… or something.