diff options
Diffstat (limited to 'make_markdown.sh')
-rwxr-xr-x | make_markdown.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/make_markdown.sh b/make_markdown.sh new file mode 100755 index 0000000..92beed2 --- /dev/null +++ b/make_markdown.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# Copyright (C) 2022 Wojtek Kosior +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the CC0 1.0 Universal License as published by +# the Creative Commons Corporation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# CC0 1.0 Universal License for more details. + +PLAIN_FILENAME=SBoM_haketilo-1.0_hydrilla-1.0.txt + +for WHICH_ONE in haketilo hydrilla; do + if [ $WHICH_ONE = haketilo ]; then + OTHER_ONE=hydrilla + else + OTHER_ONE=haketilo + fi + OTHER_CAP=$(printf $OTHER_ONE | tr h H) + + export NOTE=" +[Software Bill of Materials (SBOM)](https://en.wikipedia.org/wiki/Software_bill_of_materials) lists external components used or included in a given software product. + +You may also want to look at the [SBOM of $OTHER_CAP](/projects/hydrilla/wiki/${OTHER_CAP}_Software_Bill_of_Materials) and [a concatenated plain text version](https://git.koszko.org/haketilo-hydrilla-sbom/plain/$PLAIN_FILENAME)." + + AWK_EXTRACT_HALF=" +/^#[[:space:]].*Haketilo/ {haketilo_part = 1; hydrilla_part = 0;} +/^#[[:space:]].*Hydrilla/ {hydrilla_part = 1; haketilo_part = 0;} +/^##[[:space:]]/ { + if (${WHICH_ONE}_part && printed_note && !printed_toc) { + print \"{{toc}}\\n\" + printed_toc = 1; + } +} +{ + if (${WHICH_ONE}_part) { + if (!printed_note) { + print \$0; + print ENVIRON[\"NOTE\"]; + printed_note = 1; + } else { + print \$0; + } + } +} +" + + awk -- "$AWK_EXTRACT_HALF" $PLAIN_FILENAME | + # email addresses + sed 's_<\([^[:space:]]\+@[^[:space:]]\+\)>_`<`\1`>`_g' | + # tables + sed 's_|\(-\+\)+\(-\+\)_|\1|\2_g' > SBoM_$WHICH_ONE-1.0.md +done |