Add alt text as title text... for the single image on my entire site

This commit is contained in:
askiiart 2024-03-12 20:45:03 -05:00
parent d47156ebba
commit ebbd2bef19
Signed by untrusted user who does not match committer: askiiart
GPG key ID: BC3800E55FB54D67
6 changed files with 19 additions and 4 deletions

View file

@ -5,7 +5,7 @@
<title>askiiart.net blog</title>
<description>The feed for askiiart.net but just the blog, I guess</description>
<link>https://askiiart.net/blog/</link>
<lastBuildDate>Thu, 07 Mar 2024 05:17:23 +0000</lastBuildDate>
<lastBuildDate>Wed, 13 Mar 2024 01:44:19 +0000</lastBuildDate>
<item>
<title>300</title>
<link>https://askiiart.net/til/300.html</link>

View file

@ -441,7 +441,7 @@
<figure>
<img
src="/assets/blog/marlin-boot-animations/marlin-linux-mint.png"
alt="Linux Mint logo, as it would appear on a 128x64 display" />
title="Linux Mint logo, as it would appear on a 128x64 display" alt="Linux Mint logo, as it would appear on a 128x64 display" />
<figcaption aria-hidden="true">Linux Mint logo, as it would
appear on a 128x64 display</figcaption>
</figure>

View file

@ -5,7 +5,7 @@
<title>askiiart.net</title>
<description>The feed for askiiart.net, I guess</description>
<link>https://askiiart.net</link>
<lastBuildDate>Thu, 07 Mar 2024 05:17:23 +0000</lastBuildDate>
<lastBuildDate>Wed, 13 Mar 2024 01:44:19 +0000</lastBuildDate>
<item>
<title>300</title>
<link>https://askiiart.net/blog/300.html</link>

View file

@ -7,4 +7,5 @@ find . -name "*.md" | while read -r item; do
echo "Currently processing ${item}"
pandoc -f markdown-smart --data-dir . --template ${dir}/template.html -t html -o ${item}.html ${item}.md --metadata title="$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)"
sed -i s/sourceCode\ /language-/g ${item}.html
python3 $dir/regex-chicanery.py ${item}.html
done

14
regex-chicanery.py Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import re
import sys
# add title attribute to img tags
filename = sys.argv[1]
with open(filename, 'r+') as f:
contents = ''.join(f.readlines())
regexp = re.compile('alt="(.*?)"')
for match in regexp.finditer(contents):
contents = contents.replace(match.group(0), f'title="{match.group(1)}" {match.group(0)}')
with open(filename, 'wt') as f:
f.write(contents)

View file

@ -5,7 +5,7 @@
<title>askiiart.net TIL</title>
<description>The feed for askiiart.net but just TIL, I guess</description>
<link>https://askiiart.net/til/</link>
<lastBuildDate>Thu, 07 Mar 2024 05:17:23 +0000</lastBuildDate>
<lastBuildDate>Wed, 13 Mar 2024 01:44:19 +0000</lastBuildDate>
<item>
<title>Akkoma in Docker</title>
<link>https://askiiart.net/til/akkoma-in-docker.html</link>