Files
infix/utils/extract-changelog.sh
Joachim Wiberg 5df26b217a utils: link to GNS3 blog instead of GNS3 marketplace
Friendlier for first-time users, and drives traffic to the blog, hopefully.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-07-01 08:26:15 +02:00

52 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
#
# Extract the latest release entry from ChangeLog.md and unwrap lines
# for GitHub's web view (lets the browser handle line wrapping).
#
# Usage: cat doc/ChangeLog.md | extract-changelog.sh > release.md
#
# Output goes to stdout.
#
set -e -o pipefail
# Extract section between first two --- lines, skip trailing blank lines
head -n -1 < <(awk '/^-----*$/{if (x == 1) exit; x=1;next}x') |
# Unwrap lines for GitHub's web view (browser does wrapping)
# Preserves: blank lines, list items, headings, blockquotes, indented blocks
# Joins: soft-wrapped paragraph/list continuations
awk '
{
if (/^$/) {
if (buf) print buf
buf = ""
print
blank = 1
next
}
if (/^ / && buf) {
# Indented continuation - strip indent and join
sub(/^ /, " ")
buf = buf $0
} else if (/^[-*>#\[|]/ || /^[0-9]+\./ || blank || !buf || brk) {
# New block: special char, after blank, first line, or after md break
if (buf) print buf
buf = $0
} else {
# Paragraph continuation - join with space
buf = buf " " $0
}
blank = 0
brk = / $/
}
END { if (buf) print buf }
'
# Append tip for GNS3
cat <<EOF
> [!TIP]
> **Try Infix in GNS3!** See the blog post for details <https://www.kernelkit.org/posts/infix-in-gns3/>
EOF