convert_man.sh (2389B)
1 #!/bin/sh 2 3 # Copyright (C) 2017-2025 |Méso|Star> (contact@meso-star.com) 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 set -e 19 20 # The following line can be translated as follows: 21 # - Convert the nroff file submitted on stdin to HTML 22 # - Remove the page header 23 # - Remove the footer 24 # - Remove invalid links (they are used as section tags) 25 # - Replace multiple non-breaking spaces with a single one 26 # - Remove the opening HTML tag tt, which is no longer supported 27 # - Remove the closing HTML tag tt, which is no longer supported 28 # - Remove the compact attribute from the HTML tag dl, which is no 29 # longer supported 30 # - Remove links on csplit, feh, gnuplot, sed, mmap, and mpirun 31 # - Correct the link to the GPLv3+ license 32 # - Remove the unexpected link on sqrt(2) 33 # - Fix man2html issues that translate the ' character to cq 34 # - Use tidy to further clean up the HTML code 35 man2html -r \ 36 | tail -n +10 \ 37 | sed '/^<HR>$/,$d' \ 38 | sed 's/\(\ \)\{1,\}/\ /g' \ 39 | sed 's/^<A NAME="[[:alpha:]]\{0,\}">\ <\/A>//g' \ 40 | sed 's/<TT>//g' \ 41 | sed 's/<\/TT>//g' \ 42 | sed 's/<DL COMPACT>/<DL>/g' \ 43 | sed -e 's/<B><A HREF="\.\.\/man1\/csplit\.1\.html">csplit<\/A><\/B>/csplit/g' \ 44 -e 's/<B><A HREF="\.\.\/man1\/feh\.1\.html">feh<\/A><\/B>/feh/g' \ 45 -e 's/<B><A HREF="\.\.\/man1\/gnuplot\.1\.html">gnuplot<\/A><\/B>/gnuplot/g' \ 46 -e 's/<B><A HREF="\.\.\/man1\/sed\.1\.html">sed<\/A><\/B>/sed/g' \ 47 -e 's/<B><A HREF="\.\.\/man1\/mpirun\.1\.html">mpirun<\/A><\/B>/mpirun/g' \ 48 -e 's/<B><A HREF="\.\.\/man2\/mmap\.2\.html">mmap<\/A><\/B>/mmap/g' \ 49 -e 's/gpl\.html\.">\(.*\).<\/A>/gpl.html">\1<\/A>./g' \ 50 -e 's/<A HREF="\.\.\/man2\/sqrt\.2\.html">sqrt<\/A>/sqrt/g' \ 51 -e "s/cq\([a-z]\)\>/'\1/g" \ 52 | tidy --show-info no -m --show-body-only yes 2>/dev/null || true