1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-10 00:12:09 +00:00

Re-add support for <samp> in markdown

This commit is contained in:
Rohan Kumar 2022-06-08 18:17:33 -07:00
parent ae0661bb7a
commit a4bcf9c4dd
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
3 changed files with 8 additions and 4 deletions

View file

@ -60,7 +60,7 @@
<!--Since language-figure doesn't seem to work for some reason just use regex to replace it-->
{{- $extraLanguageFigure := `<pre><code class="language-figure">` -}}
{{- $replacedLanguageFigure := `<pre tabindex="0"><code translate="no" itemprop="text">` -}}
{{- $extraLanguageFigure := `<pre><(code|samp) class="language-figure">` -}}
{{- $replacedLanguageFigure := `<pre tabindex="0"><${1} translate="no" itemprop="text">` -}}
{{- .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $badNoteRef $goodNoteRef | replaceRE $endnotesClosingDiv $endnotesClosingSection | replaceRE $combinedTerm $splitTerm | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | replaceRE $repeatedFootnoteBacklinksBad $repeatedFootnoteBacklinksGood | replaceRE $endNotesNotFocusable $endNotesFocusable | replaceRE $extraLanguageFigure $replacedLanguageFigure | replaceRE `\&rsquo;` `` | replaceRE `\&nbsp;` `&#160;` | replaceRE `\&ldquo;` `“` | replaceRE `\&rdquo;` `”` | replaceRE `\&hellip;` `—` | replaceRE `\&mdash;` `—` | replaceRE `\&shy;` `&#173;` | replaceRE `&lsquo;` ``| safeHTML -}}

View file

@ -8,5 +8,9 @@
just use the beginning for the label and the full thing for the aria description.
-->
<figure aria-labelledby="{{ $id }}" itemprop="hasPart" itemscope="" itemtype="https://schema.org/SoftwareSourceCode">
{{ if .Get "samp" -}}
{{ .Inner | .Page.RenderString | replaceRE "<code" "<samp" | replaceRE "</code>" "</samp>" | safeHTML -}}
{{- else -}}
{{ .Inner | .Page.RenderString -}}
{{- end }}
</figure>

View file

@ -31,8 +31,8 @@ sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | sd '^\t' '' >"
cat tmp.css
# shellcheck disable=SC2016 # these are regex statements, not shell expressions
tail -n +8 "$tmp_file" \
| sd '<pre(?: tabindex="0")?>\n\t*<code ' '<pre tabindex="0"><code ' \
| sd '(?:\n)?</code>\n(?:[\t\s]*)?</pre>' '</code></pre>' \
| sd '<pre(?: tabindex="0")?>\n\t*<(code|samp) ' '<pre tabindex="0"><$1 ' \
| sd '(?:\n)?</(code|samp)>\n(?:[\t\s]*)?</pre>' '</$1></pre>' \
| sd '</span>.span itemprop="familyName"' '</span> <span itemprop="familyName"' \
| sd '</picture><span itemprop="name" class="p-name fn n">' '</picture> <span itemprop="name" class="p-name fn n">' \
| sd '([a-z])<(data|time)' '$1 <$2'