diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-10-20 21:46:39 +0200 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-22 19:49:28 +0300 |
commit | 2e613db999a00b50ac8ab533c8820df27bc8a8da (patch) | |
tree | 9fa8ecebaddb3efd15eb76307185bfb138bec8d8 | |
parent | 7e52b6fa2464b41c5e67c57b023a9ad063eb61ca (diff) | |
download | serenity-2e613db999a00b50ac8ab533c8820df27bc8a8da.zip |
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".
-rwxr-xr-x | Meta/build-manpages-website.sh | 23 | ||||
-rw-r--r-- | Meta/convert-markdown-links.lua | 1 |
2 files changed, 12 insertions, 12 deletions
diff --git a/Meta/build-manpages-website.sh b/Meta/build-manpages-website.sh index 8074012472..56b4a1806c 100755 --- a/Meta/build-manpages-website.sh +++ b/Meta/build-manpages-website.sh @@ -18,7 +18,7 @@ fi for d in "${MAN_DIR}"*/; do dir_name=$(basename "$d") section="${dir_name/man}" - mkdir -p "output/${section}" + mkdir -p "output/${dir_name}" done # Convert markdown to html @@ -26,26 +26,27 @@ done # 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. -find "${MAN_DIR}" -iname '*.md' -type f -exec sh -c '\ - relative_path="$(realpath --relative-to="${MAN_DIR}" $0)" \ - && stripped_path="${relative_path#man}" \ - && section="${stripped_path%%/*}" \ - && filename="${stripped_path#*/}" \ - && 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}" \ -' {} \; +for md_file in "${MAN_DIR}"*/*.md; do + relative_path="$(realpath --relative-to="${MAN_DIR}" "${md_file}")" + section="${relative_path%%/*}" + section_number="${section#man}" + filename="${relative_path#*/}" + name="${filename%.md}" + 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 for d in output/*/; do 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 filename=$(basename "$f") name="${filename%.html}" if [[ "$filename" == "index.html" ]]; then continue 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 echo "</body></html>" >> "$d/index.html" done diff --git a/Meta/convert-markdown-links.lua b/Meta/convert-markdown-links.lua index 0f960e5656..0a1800b23d 100644 --- a/Meta/convert-markdown-links.lua +++ b/Meta/convert-markdown-links.lua @@ -1,5 +1,4 @@ function Link(el) 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 end |