-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconvert-adoc.sh
executable file
·32 lines (25 loc) · 1.06 KB
/
convert-adoc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Function to process a single file
process_file() {
local input_file="$1"
local base_name=$(basename "$input_file" .adoc)
local dir_name=$(dirname "$input_file")
local output_file="input/docs/${dir_name}/${base_name}.md"
input_dir=`dirname $input_file`
mkdir -p "output/$input_dir"
# Reduce file so that all includes are resolved and convert to asciidoc
# requires https://github.com/opendevise/downdoc and https://github.com/asciidoctor/asciidoctor-reducer
asciidoctor-reducer "external/skupper-docs/$input_file" | python python/process.py | downdoc -o "$output_file" -
# Extract the title from the output HTML file
title=$(head -1 "$output_file" |sed -e 's/# //g')
# Insert the title at the beginning of the output file
sed -i "1s;^;---\ntitle: $title\n---\n;" "$output_file"
}
# Check if at least one input file is provided
if [ "$#" -eq 0 ]; then
echo "Usage: $0 <input-file-1> [input-file-2] ..."
exit 1
fi
# Process each file passed as an argument
for input_file in "$@"; do
process_file "$input_file"
done