From 5877ad10d45de3b30c48752b9b3fcf9ec500e524 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 6 Jul 2022 18:01:21 +0200 Subject: updat --- .local/bin/mutt_md2html.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to '.local') diff --git a/.local/bin/mutt_md2html.sh b/.local/bin/mutt_md2html.sh index 9915f96..a7e3ebe 100755 --- a/.local/bin/mutt_md2html.sh +++ b/.local/bin/mutt_md2html.sh @@ -11,12 +11,15 @@ img_count=$(grep -Eo '!\[[^]]*\]\([^)]+' "$markdown_file" | cut -d '(' -f 2 | grep -Evc '^(cid:|https?://)') if [ "$img_count" -gt 0 ]; then + printf '' >>"$commands_file" + printf '"%s"' \ + "$markdown_file" >>"$commands_file" grep -Eo '!\[[^]]*\]\([^)]+' "$markdown_file" | cut -d '(' -f 2 | grep -Ev '^(cid:|https?://)' | while read -r file; do real_file=$(echo "$file" | sed "s#~#$HOME#g") id="cid:$(md5 "$real_file" | rev | cut -d ' ' -f 1 | rev)" - sed -i '.orig' "s#$file#$id#g" "$markdown_file" + sed -i '' "s#$file#$id#g" "$markdown_file" { printf '"%s"' "$real_file" printf '' @@ -24,9 +27,6 @@ if [ "$img_count" -gt 0 ]; then printf '' } >>"$commands_file" done - printf '' >>"$commands_file" - printf '"%s"' \ - "$markdown_file" >>"$commands_file" fi pandoc -f markdown -t html5 --standalone "$markdown_file" >"$html_file" @@ -38,7 +38,6 @@ pandoc -f markdown -t html5 --standalone "$markdown_file" >"$html_file" printf '' printf '' } >>"$commands_file" - # if [ "$img_count" -gt 0 ]; then # grep -Eo '!\[[^]]*\]\([^)]+' "${markdown_file}.orig" | cut -d '(' -f 2 | # grep -Ev '^(cid:|https?://)' | -- cgit v1.2.3