Avoid indentation so the embedded html is parsed right

Use one html line per map.
This commit is contained in:
Gunter Labes 2025-03-10 23:13:41 +01:00
parent bd6f250c12
commit 6f085ffa6d
No known key found for this signature in database
GPG Key ID: C0C7B971CC910216

View File

@ -60,12 +60,11 @@ jobs:
json=$(curl -s -F image=@diff_image.png https://api.imgur.com/3/upload | tee /dev/stderr)
log 'Generating HTML comment...'
html=$(printf %s "$json" | jq -rRs --arg path "$map_path" --arg dim "$old_dim -> $new_dim" '. as $input |
try fromjson catch ({error:$input}) | @html "
<h3>\($path)</h3><p>dimensions: \($dim)</p>
<img src=\"\(.data.link)\" alt=\"\(if .data.link then "map diff image" else "image upload failed" end)\"/><br/>
<details><summary>imgur response</summary><p>\(tojson)</p></details>"')
comment_body+=$html
# careful with leading spaces in the output since it is ultimately markdown (with embedded html) so the indentation may have meaning
html=$(printf %s "$json" | jq -rRs --arg path "$map_path" --arg dim "$old_dim ➔ $new_dim" '. as $input |
try fromjson catch ({error:$input}) | (if .data.link then "map diff image" else "image upload failed" end) as $alt |
@html "<h3>\($path)</h3><p>dimensions: \($dim)</p><img src=\"\(.data.link)\" alt=\"\($alt)\"/><br/><details><summary>imgur response</summary><p>\(tojson)</p></details>"')
comment_body+=$html$'\n'
done
[[ $comment_body ]] || err Failed to generate comment