Skip to content

Commit 22142ab

Browse files
committed
fix TOC links with leading punctuation
1 parent 427b8e9 commit 22142ab

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

guides/_plugins/api_doc.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def render(context)
105105
#{headers.map do |h|
106106
depth = h.count("#")
107107
text = h.gsub(/^#+ /, "")
108-
target = text.downcase.gsub(/[^a-z0-9]+/, "-").sub(/-$/, "")
108+
target = text.downcase
109+
.gsub(/[^a-z0-9]+/, "-")
110+
.sub(/-$/, "")
111+
.sub(/^-/, "")
112+
109113
rendered_text = Kramdown::Document.new(text, auto_ids: false)
110114
.to_html
111115
.sub("<p>", "")

0 commit comments

Comments
 (0)