Skip to content

Commit 5893f19

Browse files
authored
Merge pull request #1 from your5e/reformat-51
Reformat the D&D 5.1 RD
2 parents 24839bc + 44da4ac commit 5893f19

3,105 files changed

Lines changed: 46502 additions & 38854 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/obsidian-vault.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Zip Obsidian vaults
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-vault:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Install tabulate
20+
run: |
21+
pip install tabulate
22+
23+
- name: Create zips
24+
run: |
25+
make assets
26+
27+
- name: Upload 51 zip
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: dnd_51_srd
31+
path: /tmp/dnd_51_srd.zip
32+
33+
- name: Upload 521 zip
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: dnd_521_srd
37+
path: /tmp/dnd_521_srd.zip
38+
39+
- name: Extract changelog
40+
if: github.ref_type == 'tag'
41+
run: |
42+
tag="${GITHUB_REF_NAME}"
43+
awk "/^## \[$tag\]/{flag=1;next}/^## \[/{flag=0}flag" CHANGELOG.md > /tmp/release_notes.md
44+
45+
- name: Create Release
46+
uses: softprops/action-gh-release@v2
47+
if: github.ref_type == 'tag'
48+
with:
49+
body_path: /tmp/release_notes.md
50+
files: |
51+
/tmp/dnd_51_srd.zip
52+
/tmp/dnd_521_srd.zip

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [Unreleased]
6+
7+
- nothing
8+
9+
## [v0.3] — 2025-10-29
10+
11+
- Renamed files in the 5.1 vault so linking is easier
12+
- Included "About the vault" and index pages (that include the legal info),
13+
opened by default
14+
15+
## [v0.2.3] - 2025-10-21
16+
17+
- First-pass release of the D&D 5.2.1 SRD Obsidian vault
18+
19+
## [v0.1] — 2025-08-07
20+
21+
- First-pass release of the D&D 5.1 SRD Obsidian vault

Makefile

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
.PHONY: flake8 test ci vaults vault51 vault521
1+
MAKEFLAGS += --no-print-directory
2+
3+
.PHONY: flake8 test ci vaults vault-dnd51 vault-dnd51-zip vault-dnd521 vault-dnd521-zip assets push pull
24

35
flake8:
46
flake8 *.py lib/*py
@@ -11,14 +13,34 @@ ci: test
1113
@bats tests/srd/srd.bats
1214
@bats tests/ci/ci.bats
1315

14-
vaults: vault51 vault521
16+
vaults: vault-dnd51 vault-dnd521
17+
18+
assets: vault-dnd51-zip vault-dnd521-zip
19+
20+
vault-dnd51:
21+
@./patches.sh dnd/51/markdown apply
22+
@python update_vault.py dnd/51/markdown dnd/51/obsidian_vault
23+
@./update_vault_indexes.sh dnd/51
24+
@./patches.sh dnd/51/obsidian_vault apply
1525

16-
vault51:
26+
vault-dnd51-zip: vault-dnd51
1727
rsync -av dnd/51/obsidian_vault/ /tmp/dnd_51_srd/
1828
(cd /tmp && zip -r dnd_51_srd.zip dnd_51_srd/)
1929

20-
vault521:
21-
python update_vault.py --profile dnd521 dnd/521/markdown dnd/521/obsidian_vault
22-
./update_vault_indexes.sh
30+
vault-dnd521:
31+
@./patches.sh dnd/521/markdown apply
32+
@python update_vault.py dnd/521/markdown dnd/521/obsidian_vault
33+
@./update_vault_indexes.sh dnd/521
34+
@./patches.sh dnd/521/obsidian_vault apply
35+
36+
vault-dnd521-zip: vault-dnd521
2337
rsync -av dnd/521/obsidian_vault/ /tmp/dnd_521_srd/
2438
(cd /tmp && zip -r dnd_521_srd.zip dnd_521_srd/)
39+
40+
push:
41+
rsync -ai --delete dnd/51/obsidian_vault/ ~/Downloads/dnd_51_srd/
42+
rsync -ai --delete dnd/521/obsidian_vault/ ~/Downloads/dnd_521_srd/
43+
44+
pull:
45+
rsync -ai --delete ~/Downloads/dnd_51_srd/ dnd/51/obsidian_vault/
46+
rsync -ai --delete ~/Downloads/dnd_521_srd/ dnd/521/obsidian_vault/

README.md

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Each is available as a whole Markdown file, smaller segments broken up in a
5151
- Re-arranged the order of the Fantasy-Historical Pantheons so that the
5252
table of deities appears in the description of that pantheon
5353
- Subclass introduction headers added to Barbarian, Bard, Cleric & Druid
54+
- The monster ability tables have been reformatted to be in a different
55+
layout -- score/modifier/saving throw -- and the "Saving Throw" line
56+
underneath removed now it is incorporated into the table
5457

5558
- D&D 5th edition 5.2.1 SRD (2024 rules)
5659

@@ -85,6 +88,8 @@ Each is available as a whole Markdown file, smaller segments broken up in a
8588
including rotating statblock tables to have the abilities in the
8689
first column
8790
- split tables using mid-table headers into multiple tables
91+
- monster ability tables have been reformatted to be in the format
92+
score/modifier/saving throw
8893

8994
## Workflow for breaking the whole SRD into sections
9095

@@ -107,117 +112,110 @@ A draft breakdown is made with
107112
```
108113

109114
and then refined by hand (as either `marker` detects far too many lines as
110-
headers, or the PDF was styled poorly). While refining the breakdown, this is
111-
run repeatedly to spot mistakes:
115+
headers, or the PDF was styled poorly). While refining the breakdown, this
116+
can be run repeatedly to spot mistakes:
112117

113118
```bash
114119
cp dnd/51/SRD_CC_v5.1.md dnd/51/breakdown.md \
115-
&& ./breakdown.sh -f dnd/51/breakdown.md \
120+
&& ./breakdown.sh -fh dnd/51/breakdown.md \
116121
&& diff -u dnd/51/SRD_CC_v5.1.md <(./rebuild.sh dnd/51/breakdown.md)
117122
```
118123

124+
119125
### Clean the Markdown
120126

121-
Run the cleaning script:
127+
Once the breakdown has been created, start looping over refinement and repair
128+
of the SRD Markdown using `./reprocess.sh`:
122129

123130
```bash
124-
python clean_srd.py --progress dnd/51/SRD_CC_v5.1.md
131+
./reprocess.sh dnd/51/SRD_CC_v5.1.md
125132
```
126133

127-
If it detects any errors it cannot fix automatically, it will issue errors and
128-
not process the file further. After reformatting the document, it will also
129-
scan for problems that might need human intervention. Any automatic changes
130-
will have updated the breakdown file as necessary.
134+
Without other arguments, it will:
131135

132-
If warnings are emitted during cleaning that can be safely ignored, they
133-
can be added to an ignore file. Similarly, if any source would be modified
134-
in an unwanted manner, those lines can be added to a file declaring them
135-
already cleaned:
136+
- `git restore` the files being cleaned, to always be working with a
137+
predictable starting base (this can be skipped with `-b`)
136138

137-
```bash
138-
python clean_srd.py \
139-
--progress \
140-
--ignore-warnings dnd/51/ignore_warnings.txt \
141-
--clean-lines dnd/51/clean_lines.txt \
142-
dnd/51/SRD_CC_v5.1.md
143-
```
139+
- run the clean script, which reformats the document to remove PDF decoding
140+
errors, change formatting to the preferred format, and scan for errors
141+
that are hard to fix programmatically (this can be skipped with `-c`)
142+
143+
```bash
144+
python clean_srd.py \
145+
--progress \
146+
$ignore_warnings \
147+
"$srd_path" "$breakdown_txt"
148+
```
149+
- break down the content to individual files (this can be skipped with `-b`)
150+
151+
- rebuild the SRD from the broken down content to compare with the original,
152+
to spot breakdown.txt problems, header level issues and more (this can
153+
be skipped with `-d`)
154+
155+
- filter the content again to create a cross-linked Obsidian vault (which is
156+
also often the easiest way to examine individual sections in isolation to
157+
find problems; this can be skipped with `-v`)
144158

145-
When changing the source by hand and lines are added/removed, use
159+
If warnings are emitted during cleaning that can be safely ignored, they can
160+
be added to an `ignore_warnings.txt` file. Similarly, if any source would be
161+
modified in an unwanted manner, those lines can be added to a
162+
`clean_lines.txt` file.
163+
164+
When changing the original SRD Markdown by hand and lines are added/removed, use
146165
`alter_lines.sh` to change the line numbers in `breakdown.txt` and
147166
`ignore_warnings.txt` from a specific point in the breakdown onwards:
148167

149168
```bash
150169
./alter_lines.sh -d dnd/51/ /black_tentacles -2
151170
```
152171

153-
### Fix header progression
172+
### Fixing header progression
154173

155174
The broken down fragments of the SRD should start with a first level header.
156-
To help this, `breakdown.sh` will fix easy segments, and warn on any where the
157-
headers skip around too much. This can be suppressed with the `-f` argument.
175+
To help this, `breakdown.sh` fixes easy segments, and warns on any where the
176+
headers skip around too much. Fixing can be turned off using the `-h` option
177+
to `reprocess.sh`, or `-f` to `breakdown.sh` if using it directly. Likewise,
178+
warnings can be supressed with `-h` to `reprocess.sh`, or `-c` when using
179+
`breakdown.sh` directly.
158180

159-
To look for general problems in header progression, use:
181+
Any warnings can be piped to `edit_warnings.sh` to open the file at the right
182+
line (in Sublime Text):
160183

161184
```bash
162-
./check_headers.sh dnd/51/markdown
163-
```
164-
165-
If there are warnings from `check_headers.sh` or `breakdown.sh` where they
166-
can't fix things automatically, they can be piped to `edit_warnings.sh` to
167-
open the file at the right line (in Sublime Text):
185+
./breakdown.sh | ./edit_warnings.sh
168186
169-
```bash
170-
./check_headers.sh dnd/51/markdown | ./edit_warnings.sh
187+
# or using the clipboard...
188+
pbpaste | ./edit_warnings.sh
171189
```
172190

173-
### Confirming the source
191+
### Patching content
174192

175-
To check the SRD master file against the broken down fragments, use:
193+
It can be helpful to add/alter content from the SRD to improve the state of
194+
the vault content, by adding links etc. From a clean git state, edit the files
195+
then run
176196

177197
```bash
178-
diff -u dnd/51/SRD_CC_v5.1.md <(./rebuild.sh dnd/51/breakdown.md)
179-
```
180-
181-
### Create an Obsidian vault
198+
# to patch the breakdown files
199+
./patches.sh dnd/51/markdown create
182200
183-
Once the SRD is edited, create a copy to use as an Obsidian vault.
184-
185-
```bash
186-
python update_vault.py \
187-
--progress \
188-
dnd/51/markdown \
189-
dnd/51/obsidian_vault
201+
# to patch only the vault
202+
./patches.sh dnd/51/obsidian_vault create
190203
```
191204

192-
Some words that are also conditions (eg invisible) may be incorrectly linked.
193-
The lines that they are on can be added to `ignore_vault.txt` so that they
194-
won't be re-created when re-running the script:
195-
196-
```bash
197-
python update_vault.py \
198-
--progress \
199-
--ignore dnd/51/ignore_vault.txt \
200-
dnd/51/markdown \
201-
dnd/51/obsidian_vault
202-
```
205+
In general, patch the original Markdown files if you want to add more content
206+
so the vault filters apply, and patch the vault if the filters are doing the
207+
wrong thing (such as linking to the condition Invisible when referring to the
208+
Invisible Stalker).
203209

204-
And where files need to be altered after the script has run in a way that
205-
would be overwritten (eg creating more wikilinks that would be removed again),
206-
after editing the files, create patches:
210+
Patches are kept rather than changing the content so that automated tests
211+
still pass when comparing the Markdown fragments to the original document.
207212

208-
```bash
209-
./vault_patches.sh create dnd/51
210-
```
211-
212-
that can then be restored later:
213-
214-
```bash
215-
./vault_patches.sh apply dnd/51
216-
```
217213

218214
## Changing the code
219215

220-
Every script should have a test suite.
216+
Every script should have a test suite. Every filter in the `clean_srd.py`
217+
and `update_vault.py` scripts should be individally tested, as well as having
218+
whole-document integration tests.
221219

222220
- `make test` runs all the code tests
223221
- `make ci` runs all the code tests, and a couple more

0 commit comments

Comments
 (0)