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

Commit

Permalink
Re-add mdbook support (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzpap authored Dec 16, 2021
1 parent 3bc29c6 commit e358117
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
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

0 comments on commit e358117

Please sign in to comment.