From 636945859b05a85b00cc6e25162e242d2420aa38 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 28 Aug 2024 13:49:47 -0700 Subject: [PATCH] Add a prefix to rule HTML IDs This adds the `r-` prefix to HTML IDs generated for rule names. This fixes a problem where the HTML IDs may conflict with existing markdown headers. For example, `## Crate` conflicts with `r[crate]`. This is done with the expectation that no headers will start with just the letter "r". --- mdbook-spec/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mdbook-spec/src/lib.rs b/mdbook-spec/src/lib.rs index 1a8a919dc..37fa81521 100644 --- a/mdbook-spec/src/lib.rs +++ b/mdbook-spec/src/lib.rs @@ -84,8 +84,8 @@ impl Spec { } } format!( - "
\ - [{rule_id}]\ + "\n" ) }) @@ -104,7 +104,7 @@ impl Spec { .iter() .map(|(rule_id, (_, path))| { let relative = pathdiff::diff_paths(path, current_path).unwrap(); - format!("[{rule_id}]: {}#{rule_id}\n", relative.display()) + format!("[{rule_id}]: {}#r-{rule_id}\n", relative.display()) }) .collect(); format!(