From 5a778c7aed78794faa53cc7109140b357d8f3571 Mon Sep 17 00:00:00 2001 From: Hugo McNally Date: Tue, 3 Sep 2024 06:53:42 +0100 Subject: [PATCH] Simplified and fixed mdbook-replace regexs 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 `/`. --- book.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/book.toml b/book.toml index 2b564d3..5b06524 100644 --- a/book.toml +++ b/book.toml @@ -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[^:#\?]*)README\.md(?P[?#].*)?', 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.*)?' +# Replace all paths pointing to something in cheriot-rtos +# to a link pointing to it in github. +regex = '^cheriot-rtos/(?P.*)?' 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}'