Add spans and classes by markdown

First of all: this is not the solution I want, because it’s basically a workaround, not “the proper way” imho.

[markup.goldmark.renderer]
  unsafe = false

Right now I have an author blurb on my site like the following:

<span class="fn n">
<a class="url" href="http://kollitsch.de/">
<span class="given-name">Patrick</span> 
<span class="family-name">Kollitsch</span>
</a>
</span>, Dipl. Ing. (FH), hat die ersten 
<span class="is-datediff" data-from="1975-07-05"></span>
&nbsp;Tage seines Lebens hinter sich und die letzten 
<span class="is-datediff" data-from="2005-01-08"></span>
&nbsp;Tage davon in 
<span class="adr country-name">Thailand</span> 
auf Koh Samui, einer kleinen aber ausreichend großen Insel im 
Golf von Thailand, zu-, ge-, &uuml;ber-, be- und verbracht.

Ignore the .is-datediff parts, that I will solve via shortcodes, but the other classes are (proper) Microformats for persons and addresses that I would like to implement and output via Markdown.

I know of Goldmarks ways to add attributes, but how about inline tags? There is no way to add a span in markdown. What might be a good way to add these classes without having a tag that has a semantic meaning (strong/hx/em/whatever) so I can add arbitrary classes to parts of the text?

Worst case is always to add shortcodes for all Microformat parts I guess, but that seems a little bit like overkill.

And as I wrote at the start - this is more a topic about how to solve this issue in general, not the quick and dirty way :slight_smile:

Hmm. Also with unsafe mode, you don’t necessarily want .md authors going wild with their own tag mark-up that may or may not be correct.

If you’re happy with duplicating data you could use JSON-LD and inject the block where-ever you want? e.g check JSON-LD tab at https://schema.org/address

But your “worst case” (shortcode(s) for whatever mix of marked-up objects you want) is probably the way to do it :grimacing: You could use partials to compose your objects (Person, Address, Phone Number, Person+Address, Person+Address+Phone-Number) that’d maybe make it less painful for authors.

1 Like

That’s right. I could add a shortcode that does this in JSON-LD and leave the text without anything… Not sure how I ended up doing this whole inline microformats thing anyway… probably some article on the wide Internet :smiley:

1 Like

The more obsessive tidy part of me tends to think “oh no, think of all those precious bytes of internet I’m wasting with the data duplication”, but any self-respecting host these days should be Brotli/gzip-ing the payloads anyway so really, it shouldn’t make all that much of a difference.

But I do dislike inline because it tends to make implementation brittle - it’s very easy accidentally to break your mark-up, layouts, or make it meaningless if surrounding mark-up (or css, for that matter!) changes.

1 Like