This commit is contained in:
Stephen Simpson
2025-01-04 08:18:27 -06:00
commit 2287678798
16 changed files with 1534 additions and 0 deletions

46
old_scripts/convert_man.sh Executable file
View File

@@ -0,0 +1,46 @@
#! /bin/bash
ROCKY_VERSION=8.10
MAN_PATH=./export/${ROCKY_VERSION}/
LOCAL_MAN_PATH=
HTML_BASE_PATH=./html_data/${ROCKY_VERSION}/
process_file() {
local file=$1
local rpm_name
rpm_name=$(echo "$file" | cut -d'/' -f 4)
local man_context
man_context=$(echo "$file" | cut -d'/' -f 8)
local man_filename
man_filename=$(echo "$file" | awk -F'/' '{print $NF}' | sed -e 's/.gz//g' -e 's/\.[0-9]*$//g')
local output_folder="${HTML_BASE_PATH}/${rpm_name}/${man_context}/"
echo "$man_filename"
mkdir -p "${output_folder}"
# Try to convert the file and capture any errors
# if ! html_content=$(zcat "$file" | groff -Thtml -P-D/dev/null -man 2>/tmp/groff_error.log | pandoc -f html -t html 2>/tmp/pandoc_error.log); then
if ! html_content=$(zcat "$file" | mandoc -T html -O fragment 2>/tmp/mandoc_error.log | python3 ./apply_template.py --rpm_name "$rpm_name" --file_name "$man_filename"); then
echo "Error processing file: $file"
cat /tmp/pandoc_error.log
return
fi
local title
title=$(echo "$html_content" | sed -n 's/.*<h1>NAME<\/h1>\s*<p>\(.*\)<\/p>/\1/p' | sed 's/<[^>]*>//g')
[ -z "$title" ] && title="$man_filename"
# Check if html_content is empty
if [ -n "$html_content" ]; then
echo -e "$html_content" > "${output_folder}${man_filename}.html"
# echo -e "---\ntitle: \"$title\"\n---\n$html_content" > "${output_folder}${man_filename}.html"
fi
}
export -f process_file
export HTML_BASE_PATH
find "$MAN_PATH" -type f | parallel --will-cite process_file