From d8a6ccbb229f1c018f9fb0d86be7064af9de3af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Carton?= Date: Thu, 1 Oct 2020 18:30:42 +0200 Subject: Add support for code blocks in markdown --- blog | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'blog') diff --git a/blog b/blog index 22cefef..14dcb1e 100755 --- a/blog +++ b/blog @@ -75,20 +75,25 @@ blog/%.html: articles/% $(addprefix templates/,$(addsuffix .html,header article_ export TAGS; \ envsubst < templates/header.html > $@; \ envsubst < templates/article_header.html >> $@; \ - sed -e 1d -e '2{/^$$/d}' \ + sed -e 1d \ -e '/^;/d' \ -e 's//\>/g' \ - -e '/^####/{s,^####,

,;s,$$,

,p;d}' \ - -e '/^###/{s,^###,

,;s,$$,

,p;d}' \ - -e '/^##/{s,^##,

,;s,$$,

,p;d}' \ - -e '/^#/{s,^#,

,;s,$$,

,p;d}' \ + -e '/^```$$/{s,.*,,;x;p;/^<\/code>/d;s,.*,
,;bT}' \
+		-e 'x;/<\/code>/{x;$$G;p;d};x' \
+		-e '/^####/{s,^####,

,;s,$$,

,;H;s,.*,,;x;p;d}' \ + -e '/^###/{s,^###,

,;s,$$,

,;H;s,.*,,;x;p;d}' \ + -e '/^##/{s,^##,

,;s,$$,

,;H;s,.*,,;x;p;d}' \ + -e '/^#/{s,^#,

,;s,$$,

,;H;s,.*,,;x;p;d}' \ -e 's,\*\*\(\([^*][^*]*\*\?\)*\)\*\*,\1,g' \ -e 's,\*\([^*][^*]*\)\*,\1,g' \ -e 's,!\[\([^]]*\)\](\([^)]*\)),\1,g' \ -e 's,\[\([^]]*\)\](\([^)]*\)),\1,g' \ -e 's,`\([^`]*\)`,\1,g' \ - -n -e '/^$$/{x;s,^,

,;s,$$,

,;p;d};H;$${x;p}' \ + -e '/^$$/{x;/^$$/d;p;d}' \ + -e 'x;/^$$/{s,.*,

,;bT};x' \ + -e ':L;$$G;p;d' \ + -e ':T;p;:t;s,<\([^/>][^>]*\)>\(\(<[^/>][^>]*>\)*\),\2,;/<[^\/>]/bt;x;/^$$/{$${x;p};d};bL' \ "$<" | envsubst >> $@; \ envsubst < templates/article_footer.html >> $@; \ envsubst < templates/footer.html >> $@; \ -- cgit v1.2.3