mirror of
https://github.com/dwmkerr/hacker-laws.git
synced 2025-12-17 04:35:12 +01:00
43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# This script prepares a `hacker-laws.md` file which is in a format ready to be
|
|
# exported to PDF or other formats for an e-book.
|
|
|
|
# Require that we provide the version number and get a date.
|
|
version=$1
|
|
date=$(date "+%Y-%m-%d")
|
|
|
|
if [ -z $version ]; then
|
|
echo "version must be specified: ./prepare-markdown-for-ebook.sh <version>"
|
|
exit 1
|
|
fi
|
|
|
|
# Create the frontmatter.
|
|
cat << EOF > frontmatter.md
|
|
---
|
|
title: "Hacker Laws"
|
|
author: "Dave Kerr, github.com/dwmkerr/hacker-laws"
|
|
subtitle: "Laws, Theories, Principles and Patterns that developers will find useful. ${version}, ${date}."
|
|
---
|
|
EOF
|
|
|
|
# Combine the frontmatter and the laws.
|
|
cat frontmatter.md README.md >> hacker-laws.md
|
|
|
|
# Remove the title - we have it in the front-matter of the doc, so it will
|
|
# automatically be added to the PDF.
|
|
sed -i'' '/💻📖.*/d' hacker-laws.md
|
|
|
|
# We can't have emojis in the final content with the PDF generator we're using.
|
|
sed -i'' 's/❗/Warning/' hacker-laws.md
|
|
|
|
# Now rip out the translations line.
|
|
sed -i'' '/^\[Translations.*/d' hacker-laws.md
|
|
|
|
# # Now rip out any table of contents items.
|
|
sed -i'' '/\*.*/d' hacker-laws.md
|
|
sed -i'' '/ \*.*/d' hacker-laws.md
|
|
|
|
# Delete everything from 'Translations' onwards (we don't need the translations
|
|
# lists, related projects, etc).
|
|
sed -i'' '/## Translations/,$d' hacker-laws.md
|