Skip to content

Commit 6369458

Browse files
committed
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".
1 parent 3e35b90 commit 6369458

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mdbook-spec/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl Spec {
8484
}
8585
}
8686
format!(
87-
"<div class=\"rule\" id=\"{rule_id}\">\
88-
<a class=\"rule-link\" href=\"#{rule_id}\">[{rule_id}]</a>\
87+
"<div class=\"rule\" id=\"r-{rule_id}\">\
88+
<a class=\"rule-link\" href=\"#r-{rule_id}\">[{rule_id}]</a>\
8989
</div>\n"
9090
)
9191
})
@@ -104,7 +104,7 @@ impl Spec {
104104
.iter()
105105
.map(|(rule_id, (_, path))| {
106106
let relative = pathdiff::diff_paths(path, current_path).unwrap();
107-
format!("[{rule_id}]: {}#{rule_id}\n", relative.display())
107+
format!("[{rule_id}]: {}#r-{rule_id}\n", relative.display())
108108
})
109109
.collect();
110110
format!(

0 commit comments

Comments
 (0)