mirror of
https://github.com/NixOS/nix.git
synced 2025-12-03 07:31:00 +01:00
Fixes #14628 - Remove mdbook-linkcheck dependency and configuration (was blocking upgrades to mdbook 0.5.0+, configured with warning-policy = "ignore" due to false positives, and redundant with lychee-based link checking) - Update substitute.py and anchors.jq to handle 'items' (mdbook 0.5.x) in addition to 'sections' (mdbook 0.4.x), as per mdbook 0.5.0 changelog: "Book::sections was renamed to Book::items" https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#05-migration-guide
38 lines
1.2 KiB
Text
Executable file
38 lines
1.2 KiB
Text
Executable file
"\\[\\]\\{#(?<anchor>[^\\}]+?)\\}" as $empty_anchor_regex |
|
|
"\\[(?<text>[^\\]]+?)\\]\\{#(?<anchor>[^\\}]+?)\\}" as $anchor_regex |
|
|
|
|
|
|
def transform_anchors_html:
|
|
. | gsub($empty_anchor_regex; "<a id=\"" + .anchor + "\"></a>")
|
|
| gsub($anchor_regex; "<a href=\"#" + .anchor + "\" id=\"" + .anchor + "\">" + .text + "</a>");
|
|
|
|
|
|
def transform_anchors_strip:
|
|
. | gsub($empty_anchor_regex; "")
|
|
| gsub($anchor_regex; .text);
|
|
|
|
|
|
def map_contents_recursively(transformer):
|
|
. + {
|
|
Chapter: (.Chapter + {
|
|
content: .Chapter.content | transformer,
|
|
sub_items: .Chapter.sub_items | map(map_contents_recursively(transformer)),
|
|
}),
|
|
};
|
|
|
|
|
|
def process_command:
|
|
.[0] as $context |
|
|
.[1] as $body |
|
|
# mdbook 0.5.x uses 'items' instead of 'sections'
|
|
if $body.items then
|
|
$body + {
|
|
items: $body.items | map(map_contents_recursively(if $context.renderer == "html" then transform_anchors_html else transform_anchors_strip end)),
|
|
}
|
|
else
|
|
$body + {
|
|
sections: $body.sections | map(map_contents_recursively(if $context.renderer == "html" then transform_anchors_html else transform_anchors_strip end)),
|
|
}
|
|
end;
|
|
|
|
process_command
|