1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

man.serenityos.org: Fix links to man(1), avoid unnecessary shells

This fixes the current bug at the end of less(1), which links to the
wrong file ".html" instead of "man.html".
This commit is contained in:
Ben Wiederhake 2021-10-20 21:46:39 +02:00 committed by Idan Horowitz
parent 7e52b6fa24
commit 2e613db999
2 changed files with 12 additions and 12 deletions

View file

@ -18,7 +18,7 @@ fi
for d in "${MAN_DIR}"*/; do for d in "${MAN_DIR}"*/; do
dir_name=$(basename "$d") dir_name=$(basename "$d")
section="${dir_name/man}" section="${dir_name/man}"
mkdir -p "output/${section}" mkdir -p "output/${dir_name}"
done done
# Convert markdown to html # Convert markdown to html
@ -26,26 +26,27 @@ done
# If you're here because your local results are different from the website: # If you're here because your local results are different from the website:
# Check that your pandoc version matches the pandoc-version specified in manpages.yaml. # Check that your pandoc version matches the pandoc-version specified in manpages.yaml.
find "${MAN_DIR}" -iname '*.md' -type f -exec sh -c '\ for md_file in "${MAN_DIR}"*/*.md; do
relative_path="$(realpath --relative-to="${MAN_DIR}" $0)" \ relative_path="$(realpath --relative-to="${MAN_DIR}" "${md_file}")"
&& stripped_path="${relative_path#man}" \ section="${relative_path%%/*}"
&& section="${stripped_path%%/*}" \ section_number="${section#man}"
&& filename="${stripped_path#*/}" \ filename="${relative_path#*/}"
&& name="${filename%.md}" \ name="${filename%.md}"
&& pandoc -f gfm -t html5 -s --lua-filter=Meta/convert-markdown-links.lua --metadata title="${name}(${section}) - SerenityOS man pages" -o "output/${section}/${name}.html" "${0}" \ pandoc -f gfm -t html5 -s --lua-filter=Meta/convert-markdown-links.lua --metadata title="${name}(${section_number}) - SerenityOS man pages" -o "output/${section}/${name}.html" "${md_file}"
' {} \; done
# Generate man page listings # Generate man page listings
for d in output/*/; do for d in output/*/; do
section=$(basename "$d") section=$(basename "$d")
echo "<!DOCTYPE html><html><head><title>Section ${section} - SerenityOS man pages</title></head><body>" > "${d}/index.html" section_number="${section#man}"
echo "<!DOCTYPE html><html><head><title>Section ${section_number} - SerenityOS man pages</title></head><body>" > "${d}/index.html"
for f in "$d"/*; do for f in "$d"/*; do
filename=$(basename "$f") filename=$(basename "$f")
name="${filename%.html}" name="${filename%.html}"
if [[ "$filename" == "index.html" ]]; then if [[ "$filename" == "index.html" ]]; then
continue continue
fi fi
echo "<a href=\"${filename}\"><p>${name}(${section})</p></a>" >> "${d}/index.html" echo "<a href=\"${filename}\"><p>${name}(${section_number})</p></a>" >> "${d}/index.html"
done done
echo "</body></html>" >> "$d/index.html" echo "</body></html>" >> "$d/index.html"
done done

View file

@ -1,5 +1,4 @@
function Link(el) function Link(el)
el.target = string.gsub(el.target, "%.md", ".html") -- change .md to .html links el.target = string.gsub(el.target, "%.md", ".html") -- change .md to .html links
el.target = string.gsub(el.target, "man", "", 1) -- change man1/???.html to 1/???.html links
return el return el
end end