Hey @RobertDober, thanks for the reply and thanks for all your work on Earmark—that is very much appreciated!
Yes, compact_output: true did not help since, as you likely well know, spans are not @compact_tags. I was able to fix it by converting the spans to ems (which I don’t mind at all since semantically they are emphasized although I’m doing it programmatically since I want to eventually integrate with makeup or vim’s :TOhtml) but then I was faced with the problem that if two tags are in a row they render without spaces. e.g.: <em class="k">SELECT</em> <em class="k">FROM</em> they render as SELECTFROM. I was actually able to solve this but in a very convoluted way:
{result, _} =
Earmark.Transform.map_ast_with(result, nil, fn
{"em", args, _, meta}, nil ->
{{"em", args, nil, meta}, :em_first}
{"em", args, _, meta}, :em_next ->
{{"em", args, nil, meta}, :em_text}
{tag, args, _, meta}, _ ->
{{tag, args, nil, meta}, nil}
text, :em_first ->
{text, :em_next}
text, :em_text ->
{" #{text}", :em_next}
node, _ ->
{node, nil}
end)
So basically saying "If we see an em for the first time, mark it as such (:em_first), then when we see its text node, do nothing other than that mark it to look out for another em (:em_next). If the next node is indeed an em, mark it that it’s part of a string of ems (still :em_next) and leftPad™ it. Anything else, just reset.
It’s a little convoluted and I haven’t revisited it since I got it working.
For all intents and purposes this solves my problems, but having a another little issue that I was going to open in the repo since it seems more appropriate to discuss there (and I want to look at the source a little more to understand if it’s reasonable or not).


















