From 00dfcc81b4ab9627460768b25aa17f19085bb335 Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Mon, 1 Dec 2025 18:45:06 +0100 Subject: [PATCH] doc: fix substitution with mdbook 0.4 Recently, in 54df89f601b3b4502a5c99173c9563495265d7e7, support for mdbook 0.5 was introduced, including some logic to handle the `sections` -> `items` rename. However, compatibility with 0.4's `sections` was only kept on the read path, while writing 0.5's `items` unconditionally, which ends up in the bit bucket on 0.4, effectively disabling substitution fully and leaving the include directives in the final documentation. Restore writing into the `sections` when they were there so that substitution works again. Change-Id: Idd4d7653012660f3f7fc27f81f29b82d6a6a6964 --- doc/manual/substitute.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/manual/substitute.py b/doc/manual/substitute.py index d14c4ca13..eda97b252 100755 --- a/doc/manual/substitute.py +++ b/doc/manual/substitute.py @@ -71,7 +71,11 @@ def do_include(content: str, relative_md_path: Path, source_root: Path, search_p def recursive_replace(data, book_root, search_path): match data: # XXX FUTURE: drop sections once mdBook is at 0.5.0 or above in nixpkgs - case {'sections': items} | {'items': items}: + case {'sections': sections}: + return data | dict( + sections = [recursive_replace(section, book_root, search_path) for section in sections], + ) + case {'items': items}: return data | dict( items = [recursive_replace(item, book_root, search_path) for item in items], )