01-convert-man-pages.sh (1366B)
1 #!/bin/sh 2 3 # Copyright (C) 2017-2025 |Méso|Star> (contact@meso-star.com) 4 # 5 # Copying and distribution of this file, with or without modification, 6 # are permitted in any medium without royalty provided the copyright 7 # notice and this notice are preserved. This file is offered as-is, 8 # without any warranty. 9 10 . "hooks/man-pages.sh" 11 12 # Man to convert is submitted on stdin 13 man2html() # output_filename 14 { 15 # Use sed to modify the generated HTML pages to remove links to manual 16 # pages that are not available locally. 17 ( 18 cd .. 19 sty-genhead "${OLDPWD##*/}/$1" 20 mandoc -O man=./%N.%S.html,fragment -T html -I os=UNIX 21 cat ./templates/footer.html 22 ) \ 23 | sed \ 24 -e 's/<a class="Xr"[^>]\{0,\}>make(1)<\/a>/<a class "Xr">make(1)<\/a>/g' \ 25 -e 's/<a class="Xr"[^>]\{0,\}>md2html(1)<\/a>/<a class "Xr">md2html(1)<\/a>/g' \ 26 -e 's/<a class="Xr"[^>]\{0,\}>rsync(1)<\/a>/<a class "Xr">rsync(1)<\/a>/g' \ 27 -e 's/<a class="Xr"[^>]\{0,\}>shellcheck(1)<\/a>/<a class "Xr">shellcheck(1)<\/a>/g' \ 28 -e 's/<a class="Xr"[^>]\{0,\}>tidy(1)<\/a>/<a class "Xr">tidy(1)<\/a>/g' \ 29 > "$1" 30 } 31 32 printf "%s\n" "${man_pages}" | while read -r i; do 33 man2html "${i}.html" < "${i}" 34 35 # Write the generated files to standard output to inform the build 36 # system which files it needs to handle during installation. 37 printf '%s/%s.html\n' "${PWD##*/}" "${i}" 38 done