meso-web

Sources of the |Méso|Star> website
git clone git://git.meso-star.fr/meso-web.git
Log | Files | Refs | README | LICENSE

commit a669ed8e3ead892b6b685aed38ece2f2b8431058
parent c2aa69525e761ff57ce6ef9cfd2752b0d54610ce
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 26 Aug 2025 10:49:15 +0200

htrdr: update mdoc to html conversion

Post-processing of generated HTML files is specific to the generated
manual pages, and therefore to the section. There is no reason for this
post-processing to be performed in a compilation system script. It has
therefore been moved to the htrdr hook responsible for generating the
HTML for the manual pages. The convert_mdoc.sh script has become
unnecessary because it only executes the mandoc command, which can be
invoked directly in the hook itself.

Note that this commit fixes problems with links to the htrdr-image
and htpp manual pages. These links were (incorrectly) post-processed
because these manual pages were considered not to be part of the current
section. This no longer makes sense since it is a local hook to htrdr
that performs this post-processing. Post-processing of links to htrdr
manual pages is only an issue for other sections.

Diffstat:
Mhtrdr/hooks/01-generate-man.sh | 18++++++++++++++++--
Dscripts/convert_mdoc.sh | 34----------------------------------
Mscripts/generate_header.sh | 48+++++++++++++++++++++++++++---------------------
3 files changed, 43 insertions(+), 57 deletions(-)

diff --git a/htrdr/hooks/01-generate-man.sh b/htrdr/hooks/01-generate-man.sh @@ -33,10 +33,24 @@ man2html() # output_filename { cd .. sh ./scripts/generate_header.sh "${OLDPWD##*/}/$1" - sh ./scripts/convert_mdoc.sh + mandoc -O man=../man%S/%N.%S.html,fragment -I os=UNIX -T html cat ./footer.html cd "${OLDPWD}" - } > "$1" + } \ + | sed \ + -e 's/"Nm">htrdr-atmosphere/"Nm">htrdr\&#8209;atmosphere/g' \ + -e 's/"Nm">htrdr-combustion/"Nm">htrdr\&#8209;combustion/g' \ + -e 's/"Nm">htrdr-image/"Nm">htrdr\&#8209;image/g' \ + -e 's/"Nm">htrdr-materials/"Nm">htrdr\&#8209;materials/g' \ + -e 's/"Nm">htrdr-planets/"Nm">htrdr\&#8209;planets/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>csplit(1)<\/a>/<a class "Xr">csplit(1)<\/a>/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>gnuplot(1)<\/a>/<a class "Xr">gnuplot(1)<\/a>/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>mmap(2)<\/a>/<a class "Xr">mmap(2)<\/a>/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>mpirun(1)<\/a>/<a class "Xr">mpirun(1)<\/a>/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>ppm(5)<\/a>/<a class "Xr">ppm(5)<\/a>/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>sysconf(3)<\/a>/<a class "Xr">sysconf(3)<\/a>/g' \ + -e 's/<a class="Xr"[^>]\{0,\}>wordexp(3)<\/a>/<a class "Xr">wordexp(3)<\/a>/g' \ + > "$1" } ######################################################################## diff --git a/scripts/convert_mdoc.sh b/scripts/convert_mdoc.sh @@ -1,34 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2017-2025 |Méso|Star> (contact@meso-star.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# 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 -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -set -e - - mandoc -O man=../man%S/%N.%S.html,fragment -I os=UNIX -T html \ -| sed -e 's/"Nm">htrdr-atmosphere/"Nm">htrdr\&#8209;atmosphere/g' \ - -e 's/"Nm">htrdr-combustion/"Nm">htrdr\&#8209;combustion/g' \ - -e 's/"Nm">htrdr-image/"Nm">htrdr\&#8209;image/g' \ - -e 's/"Nm">htrdr-materials/"Nm">htrdr\&#8209;materials/g' \ - -e 's/"Nm">htrdr-planets/"Nm">htrdr\&#8209;planets/g' \ - -e "s#href=\"../man1/htpp.1.html\"#href=\"${worktree}htrdr/man/man1/htpp.1.html\"#g" \ - -e "s#href=\"../man5/htrdr-image.5.html\"#href=\"${worktree}htrdr/man/man5/htrdr-image.5.html\"#g" \ - -e 's/<a class="Xr"[^>]\{0,\}>csplit(1)<\/a>/<a class "Xr">csplit(1)<\/a>/g' \ - -e 's/<a class="Xr"[^>]\{0,\}>gnuplot(1)<\/a>/<a class "Xr">gnuplot(1)<\/a>/g' \ - -e 's/<a class="Xr"[^>]\{0,\}>mmap(2)<\/a>/<a class "Xr">mmap(2)<\/a>/g' \ - -e 's/<a class="Xr"[^>]\{0,\}>mpirun(1)<\/a>/<a class "Xr">mpirun(1)<\/a>/g' \ - -e 's/<a class="Xr"[^>]\{0,\}>ppm(5)<\/a>/<a class "Xr">ppm(5)<\/a>/g' \ - -e 's/<a class="Xr"[^>]\{0,\}>sysconf(3)<\/a>/<a class "Xr">sysconf(3)<\/a>/g' \ - -e 's/<a class="Xr"[^>]\{0,\}>wordexp(3)<\/a>/<a class "Xr">wordexp(3)<\/a>/g' diff --git a/scripts/generate_header.sh b/scripts/generate_header.sh @@ -25,10 +25,33 @@ set -e # Print the absolute dir of the input file absdir() # file { - cd -- "$(dirname "$1")" && pwd - cd "${OLDPWD}" + if [ -d "$1" ]; then + cd -- "$1" || exit 1 + else + cd -- "$(dirname "$1")" || exit 1 + fi + echo "${PWD}" + cd "${OLDPWD}" || exit 1 } +# Print relative path from input file to a dir +relpath_to_dir() # file, dir +( + # Build directory from worktree to path + _dir0="$(absdir "$1")" + _dir1="$(absdir "$2")" + _dir0="$(printf '%s\n' "${_dir0}" | sed "s;^${_dir1}[/]\{0,\};;g")" + + # Ensure that the directory is a subpath of the worktree + if ! [ -d "${_dir0}" ]; then + return 1 + fi + + echo "${_dir0}" | sed 's/\//\n/g' | while read -r _i; do + printf "../" + done +) + # List the indexed content in TSV format. Each line contains the index # label, followed by the indexed content, and possibly an indicator of # the language used. @@ -59,23 +82,6 @@ indexed_content() done ) -# Print relative path from input file to worktree -relpath_to_worktree() # file -( - # Build directory from worktree to path - _dir="$(absdir "$1")" - _dir="$(printf '%s\n' "${_dir}" | sed "s;^${worktree}[/]\{0,\};;g")" - - # Ensure that the directory if a subpath of the worktree - if ! [ -d "${_dir}" ]; then - return 1 - fi - - echo "${_dir}" | sed 's/\//\n/g' | while read -r _i; do - printf "../" - done -) - print_head() { printf '<!DOCTYPE html>\n' @@ -200,7 +206,7 @@ fi # Define the absolute path of the working directory, i.e. the root # directory of the site, and enter it. -worktree="$(absdir "${0%%/*}")" +worktree="$(absdir "$(dirname "$0")/../")" cd "${worktree}" # Define the section directory where the input file is located, i.e., the @@ -247,7 +253,7 @@ if [ -n "${subentry}" ]; then fi lang="${lang:-en}" -root="$(relpath_to_worktree "$1")" +root="$(relpath_to_dir "$1" "${worktree}")" print_head print_menu1