summaryrefslogtreecommitdiff
path: root/http/bin
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-09-08 18:48:15 +0100
committerJoe Carstairs <me@joeac.net>2026-09-08 18:48:15 +0100
commitf5602bab371a3f3a1fb5aced4ec4822c35a9ca5d (patch)
treedfcbd4145ced4f2e4f4297fbfa493b8999c28567 /http/bin
parent15240a17d06ebf8d95d86896bc87ad9c633ea71d (diff)
omit first line break in preformatted block
Diffstat (limited to 'http/bin')
-rwxr-xr-xhttp/bin/gmi2upphtml12
1 files changed, 9 insertions, 3 deletions
diff --git a/http/bin/gmi2upphtml b/http/bin/gmi2upphtml
index 044bedd..3d36409 100755
--- a/http/bin/gmi2upphtml
+++ b/http/bin/gmi2upphtml
@@ -5,6 +5,7 @@ post_title="${POST_TITLE:-}"
is_in_list=0
is_in_link_block=0
is_in_preformatted_block=0
+is_first_line_of_preformatted_block=0
is_in_blockquote=0
if_in_list_then_close()
@@ -105,12 +106,17 @@ while read line
do
if [ $is_in_preformatted_block -ne 0 ]
then
+ if [ $is_first_line_of_preformatted_block -ne 0 ]
+ then
+ prefix="<pre><code>"
+ is_first_line_of_preformatted_block=0
+ fi
if [ "$(echo "$line" | cut -c1-3)" = "\`\`\`" ]
then
- echo "</code></pre>"
+ echo "${prefix}</code></pre>"
is_in_preformatted_block=0
else
- echo "$(escape_upphtml "${line}")"
+ echo "${prefix}$(escape_upphtml "${line}")"
fi
continue
fi
@@ -178,8 +184,8 @@ do
if [ "$(echo "$line" | cut -c1-3)" = "\`\`\`" ]
then
close_all_open_blocks_except pre
- echo "<pre><code>"
is_in_preformatted_block=1
+ is_first_line_of_preformatted_block=1
continue
fi