Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Re-enable mdbook support #46

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[book]
title = "The Tangle Improvement Proposal (TIP) Book"

[output.html]
no-section-label = true
16 changes: 16 additions & 0 deletions format_tip_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
C=0
touch tmp
while IFS= read -r line
do
if [[ $line == "---" && "$C" -eq 0 ]]; then
((C++))
line="<pre>"
fi
if [[ $line == "---" && "$C" -eq 1 ]]; then
((C++))
line="</pre>"
fi
echo $line >> tmp
done < "$1"

mv tmp $1
34 changes: 34 additions & 0 deletions generate_book.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# SPDX-License-Identifier: Apache-2.0
# Source: https://github.com/rust-lang/rfcs/blob/85c95c7179acc8986eae709f773ff3a91f1e2e43/generate-book.sh

set -e

rm -rf src
mkdir src
cp -r tips src

printf '[Introduction](introduction.md)\n\n' > src/SUMMARY.md

# create summary, extract tip titles and numbers
find ./src ! -type d -name '*.md' ! -path ./src ! -path ./src/SUMMARY.md -print0 \
| sed -e 's/.\/src\///g' \
| sort -z \
| while read -r -d '' file;
do
tipNum=$(sed 's/-0*/-/' <<< $(basename "$file" ".md"))
printf -- '- [%s%s](%s)\n' ${tipNum^^} "$(sed -n 's/^title:\(.*\)$/\1/p' < $file)" "$file"
done >> src/SUMMARY.md

# remove "---" from tip header and replace it h <pre> and </pre>
find ./src ! -type d -name '*.md' ! -path ./src ! -path ./src/SUMMARY.md -print0 \
| sort -z \
| while read -r -d '' file;
do
./format_tip_header.sh $file
done

ln -frs README.md src/introduction.md

mdbook build