Skip to content

Commit 051fc9f

Browse files
committed
Add a comment about the intent of HTML id generation
1 parent d0bde46 commit 051fc9f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/mdbook-html/src/utils.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ pub(crate) fn unique_id(id: &str, used: &mut HashSet<String>) -> String {
7474

7575
/// Generates an HTML id from the given text.
7676
pub(crate) fn id_from_content(content: &str) -> String {
77+
// This is intended to be close to how header ID generation is done in
78+
// other sites and tools, but is not 100% the same. Not all sites and
79+
// tools use the same algorithm. See these for more information:
80+
//
81+
// - https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
82+
// - https://docs.gitlab.com/user/markdown/#heading-ids-and-links
83+
// - https://pandoc.org/MANUAL.html#extension-auto_identifiers
84+
// - https://kramdown.gettalong.org/converter/html#auto-ids
85+
// - https://docs.rs/comrak/latest/comrak/options/struct.Extension.html#structfield.header_ids
7786
content
7887
.trim()
7988
.to_lowercase()

0 commit comments

Comments
 (0)