diff --git a/lib/search.js b/lib/search.js index 93613c1..26d6cca 100644 --- a/lib/search.js +++ b/lib/search.js @@ -47,6 +47,7 @@ function search(root, expression, settings) { function onheading(child, index, parent) { var value = toString(child) var id = child.data && child.data.hProperties && child.data.hProperties.id + var slug = slugs.slug(id || value) if (!parents(parent)) { return @@ -73,7 +74,7 @@ function search(root, expression, settings) { map.push({ depth: child.depth, children: child.children, - id: slugs.slug(id || value) + id: slug }) } } diff --git a/test/fixtures/custom-heading/input.md b/test/fixtures/custom-heading/input.md index 2714456..75adc75 100644 --- a/test/fixtures/custom-heading/input.md +++ b/test/fixtures/custom-heading/input.md @@ -10,4 +10,6 @@ Text. ## Something elsefi +## Normal + # Something iffi diff --git a/test/fixtures/custom-heading/output.json b/test/fixtures/custom-heading/output.json index 600984e..845f299 100644 --- a/test/fixtures/custom-heading/output.json +++ b/test/fixtures/custom-heading/output.json @@ -74,6 +74,28 @@ ] } ] + }, + { + "type": "listItem", + "spread": false, + "children": [ + { + "type": "paragraph", + "children": [ + { + "type": "link", + "title": null, + "url": "#normal-1", + "children": [ + { + "type": "text", + "value": "Normal" + } + ] + } + ] + } + ] } ] }