docs: Hide PDF metadata from rendered markdown in github

This commit is contained in:
Tyler Wilding 2021-03-25 22:54:13 -04:00 committed by lightningterror
parent 51253193e0
commit 72eafeaf40
6 changed files with 31 additions and 19 deletions

Binary file not shown.

View File

@ -1,9 +1,9 @@
---
<!-- PDF METADATA STARTS ---
title: "PCSX2 - Configuration Guide"
date: "2020"
footer-left: "[Document Source](https://github.com/PCSX2/pcsx2/blob/{LATEST-GIT-TAG}/pcsx2/Docs/Configuration_Guide/Configuration_Guide.md)"
urlcolor: "cyan"
...
... PDF METADATA ENDS -->
# PCSX2 First Time Setup and Configuration
This guide will walk through the initial setup process of PCSX2 and the basics of configuration.

View File

@ -1,9 +1,9 @@
---
<!-- PDF METADATA STARTS ---
title: "PCSX2 - Debugger Documentation"
date: "2021"
footer-left: "[Document Source](https://github.com/PCSX2/pcsx2/blob/{LATEST-GIT-TAG}/pcsx2/Docs/Debugger.md)"
urlcolor: "cyan"
...
... PDF METADATA ENDS -->
# Debugger Key Bindings

View File

@ -1,9 +1,9 @@
---
<!-- PDF METADATA STARTS ---
title: "PCSX2 - GameDB Documentation"
date: "2021"
footer-left: "[Document Source](https://github.com/PCSX2/pcsx2/blob/{LATEST-GIT-TAG}/pcsx2/Docs/GameIndex.md)"
urlcolor: "cyan"
...
... PDF METADATA ENDS -->
# GameDB Documentation

View File

@ -1,9 +1,9 @@
---
<!-- PDF METADATA STARTS ---
title: "PCSX2 Frequently Asked Questions"
date: "2021"
footer-left: "[Document Source](https://github.com/PCSX2/pcsx2/blob/{LATEST-GIT-TAG}/pcsx2/Docs/PCSX2_FAQ.md)"
urlcolor: "cyan"
...
... PDF METADATA ENDS -->
# PCSX2 - Frequently Asked Questions

View File

@ -5,25 +5,37 @@
LATEST_SEMVER=$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/PCSX2/pcsx2.git 'v*[0-9].*[0-9].*[0-9]' | tail --lines=1 | cut --delimiter='/' --fields=3)
OUT_DIR=${OUT_DIR:-"../../bin/docs"}
GIT_TAG_PATTERN="{LATEST-GIT-TAG}"
PDF_METADATA_START_PATTERN="<!-- PDF METADATA STARTS "
PDF_METADATA_END_PATTERN=" PDF METADATA ENDS -->"
## Generate and Move Markdown->PDFs
### Configuration Guide
prepare_markdown_file() {
ORIG_FILE="$1".md
TEMP_FILE="$1".temp.md
TEMPLATE_FILE="$2"
OUTPUT_PDF_FILE="$1".pdf
cp "$ORIG_FILE" "$TEMP_FILE"
# Make PDF Metadata Visible
sed -i 's/'"$PDF_METADATA_START_PATTERN"'//' "$TEMP_FILE"
sed -i 's/'"$PDF_METADATA_END_PATTERN"'//' "$TEMP_FILE"
# Update Git Tag
sed -i 's/'"$GIT_TAG_PATTERN"'/'"$LATEST_SEMVER"'/' "$TEMP_FILE"
# Render PDF
pandoc --template "$TEMPLATE_FILE" --toc "$TEMP_FILE" -o "$OUTPUT_PDF_FILE"
# Delete Temp File
rm "$TEMP_FILE"
}
### Configuration Guide, handled differently as it's in it's own folder
pushd ./Configuration_Guide
cp Configuration_Guide.md Configuration_Guide.temp.md
sed -i 's/{LATEST-GIT-TAG}/'"$LATEST_SEMVER"'/' Configuration_Guide.temp.md
pandoc --template ../eisvogel.tex --toc Configuration_Guide.temp.md -o Configuration_Guide.pdf
rm Configuration_Guide.temp.md
prepare_markdown_file "Configuration_Guide" "../eisvogel.tex"
popd
mv -f ./Configuration_Guide/Configuration_Guide.pdf "$OUT_DIR"
### The rest!
find . -maxdepth 1 -name "*.md" -not -path "./README.md" | while read filename; do
filename="${filename%.*}"
cp "$filename.md" "$filename.temp.md"
sed -i 's/{LATEST-GIT-TAG}/'"$LATEST_SEMVER"'/' "$filename.temp.md"
pandoc --template ./eisvogel.tex --toc "$filename.temp.md" -o "$filename.pdf"
mv -f "$filename.pdf" "$OUT_DIR"
rm "$filename.temp.md"
prepare_markdown_file "$filename" "eisvogel.tex"
done