Implement accessible drop-cap

Oh, man. I was almost there. Eh, guess I’ll leave my attempt here anyway:

{{ $firstP := `(?:^<p>((\b[a-zA-Z])([\w\-]+))((?:.|\n)+?)</p>)` }}
{{ $withDropCapDom := printf "<p class=\"the-first-paragraph\"><span aria-hidden=\"true\"><span class=\"dropcap\">${2}</span>${3}</span><span class=\"sr-only\">${1}</span>${4}</p>" }}

{{ .Content | replaceRE $firstP $withDropCapDom | safeHTML }}
1 Like