Hacking render-link.html to produce about any kind of html tags: THANKS ;-)

I just wanted to comment how badass links renderhooks are, as I realized we can tweak them to code for any element or code whatsoever. I mean all hooks can do that, but the syntax for links is both so simple, and in semantically close enough so that it doesn’t feel unnatural.

{{- $destination := .Destination }}
{{ if or (in $destination (slice "ADD_REF" "#")) (eq .Text '#')}}
	{{.Text}}
{{else if eq $destination "DFN"}}
	{{$destination = strings.TrimPrefix "DFN" $destination}}
	<dfn title="{{.Title}}">{{.Text}}</dfn>
{{else if eq $destination "ABBR"}}
	<abbr title="{{.Title}}">{{.Text}}</abbr>	
{{else}}

Truly amazing, There’s hardly any need to complicate Markdown once you’ve mastered this.
And more importantly, though abbrevations are not repeated automatically in the whole text, by using this syntax such feature would be rendered redundant:

[AOL] is the worst internet provider I ever used. Now whenever [AOL] is typed as such, the abbrevation comes back.

[AOL](ABBR "America Online")

One could insert about any element like this, with the absolute minimum syntactic sugar conceivable.

7 Likes