core-lightning/tools/md2man.sh
ShahanaFarooqui 54555ce5e7 doc: Add new createrune example
- Moved the `Usage` section further down in `createrune` and `commando-rune` for improved UX.
- Added a new example for creating a rune with `read-only` restrictions, extending it to allow only payments of `less than 100,000 sats per day` using the `pay` or `xpay` methods.
- Adjusted formatting by appending an extra space after the `dependentUpon` condition, fixing `[*start* [*end*]][*relist*]` to `[*start* [*end*]] [*relist*]`.
- Relocated `Examples` from the expandable section to a standard heading, as examples are now already placed at the end of the page.

Changelog-None.
2025-02-04 20:12:59 +10:30

29 lines
1.1 KiB
Bash
Executable file

#! /bin/sh
if [ $# != 2 ]; then
echo "Usage: $0 <lowdown> <markdownpage>" >&2
exit 1
fi
LOWDOWN="$1"
SOURCE="$2"
SECTION="$(basename "$SOURCE" .md | cut -d. -f2-)"
TITLE="$(basename "$(basename "$SOURCE" .md)" ."$SECTION" | tr '[:lower:]' '[:upper:]')"
# First two lines are title, which needs to be turned into NAME for proper manpage
# format. mrkd used to do this for us, lowdown(1) doesn't.
TITLELINE="$(head -n1 "$SOURCE")"
# Replace lightning-cli with $ lightning-cli but do not replace it if it is preceded with (
# because it is used in the examples to run it in the shell, eg. $(lightning-cli listpeerchannels)
SOURCE=$(tail -n +3 "$SOURCE" | sed -E '
:a;N;$!ba;
s#EXAMPLES\n------------#\nEXAMPLES\n------------\n#g;
s#Request:#Request:\n#g;
s#Response:#Response:\n#g;
s#(\(lightning-cli)#\x1#ig;
s#lightning-cli#$ lightning-cli#g;
s#\x1#(lightning-cli#g;
s#\*\*Notification (1|2|3)\*\*:#**Notification \1**:\n#g;
')
(echo "NAME"; echo "----"; echo "$TITLELINE"; echo "$SOURCE") | $LOWDOWN -s --out-no-smarty -Tman -m "title:$TITLE" -m "section:$SECTION" -m "source:Core Lightning $VERSION" -m "shiftheadinglevelby:-1"