Skip to content

Commit

Permalink
Simplified and fixed mdbook-replace regexs
Browse files Browse the repository at this point in the history
The local file replacement for files in the repository
was capturing markdown files. The new regex is a white list.
Note, it only assumes something is a register if it ends with `/`.
  • Loading branch information
HU90m authored and marnovandermaas committed Sep 3, 2024
1 parent edead64 commit 5a778c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ edit-url-template = "https://github.com/lowRISC/sonata-software/edit/main/{path}
[preprocessor.replace]
after = ["links"]

# Replace all links to a README.md to an index.md
# Replace all links to a README.md to with a link to an index.md
link_replacements = [
{regex = '^(?P<path>[^:#\?]*)README\.md(?P<suffix>[?#].*)?', replacement = '${path}index.md${suffix}'},
]

[[preprocessor.replace.local_link_replacements]]
# Replace all paths pointing to something in the cheriot-rtos
# to a link pointing to them in github.
regex = '^cheriot-rtos/*(?P<path>.*)?'
# Replace all paths pointing to something in cheriot-rtos
# to a link pointing to it in github.
regex = '^cheriot-rtos/(?P<path>.*)?'
replacement = 'https://github.com/CHERIoT-Platform/cheriot-rtos/tree/main/${path}'

[[preprocessor.replace.local_link_replacements]]
# Replace all paths pointing to something in this repository,
# that is not a markdown file or image,
# to a link pointing to them in github.
regex = '[^:#\?]*[^(\.(md|svg|png))]([?#].*)?'
# that ends with .cc, .hh, .h, .rego, .lua or / (for directories)
# to a link pointing to to in github.
regex = '.*(\/|\.(cc|hh|h|rego|lua))$'
replacement = 'https://github.com/lowRISC/sonata-software/tree/main/${0}'

0 comments on commit 5a778c7

Please sign in to comment.