Skip to content

Commit 06106bb

Browse files
authoredOct 30, 2023
Util: Move toc ID in parseMarkdown from icon to heading
Currently, the heading IDs are not actually on the heading elements. This means that scrapers such as Algolia and Typesense often link text excerpts under a heading to something far away like `#content` instead of the nearest preceeding heading. For semantics, and to benefit search suggestions, I think the heading IDs are better suited on headings. Closes gh-90 Ref jquery/infrastructure-puppet#33
1 parent 6cc209a commit 06106bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎lib/util.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function parseMarkdown( src, options ) {
4747
item.pre = false;
4848

4949
// Insert the link
50-
item.text = "<h" + item.depth + " class='toc-linked'>" +
51-
"<a href='#" + item.tocId + "' id='" + item.tocId + "' class='icon-link toc-link'>" +
50+
item.text = "<h" + item.depth + " class='toc-linked' id='" + item.tocId + "'>" +
51+
"<a href='#" + item.tocId + "' class='icon-link toc-link'>" +
5252
"<span class='visuallyhidden'>link</span>" +
5353
"</a> " + parsedText + "</h" + item.depth + ">";
5454

0 commit comments

Comments
 (0)
Please sign in to comment.