File: md2man

package info (click to toggle)
android-platform-build-kati 10.0.0%2Br32%2Bgit20220314.09dfa26c4e59-7.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,628 kB
  • sloc: cpp: 10,340; sh: 1,087; python: 85; makefile: 46
file content (19 lines) | stat: -rwxr-xr-x 451 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

if [ -x /usr/bin/pandoc ]
then
    pandoc "$1" -t man -s -o "$2"
    exit 0
fi

get_header() {
    grep "$2:" "$1" | cut -d ' ' -f 2-
}

sed -e '/---/,/---/d' \
    -e '/## NAME/,+2 {/## NAME/d; s/^.*-/# /}' "$1" | \
    ronn --roff --pipe \
        --manual="$(get_header "$1" header)" \
        --name "$(get_header "$1" title)" \
        --organization "$(get_header "$1" footer)" \
        --section "$(get_header "$1" section)" > "$2"