Skip to content

Commit

Permalink
Upgrade anchor-markdown-header to fix emoji-titled headers (thloren…
Browse files Browse the repository at this point in the history
…z#232)

* Add test for emoji-titled headers

This provides an example of the problem described in thlorenz#191.

* Upgrade `anchor-markdown-header` to fix emoji-titled headers

Fixes thlorenz#191
  • Loading branch information
Kevin David authored Sep 22, 2022
1 parent 2ed48a3 commit bb82960
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"bin": "doctoc.js",
"dependencies": {
"@textlint/markdown-to-ast": "^12.1.1",
"anchor-markdown-header": "^0.5.7",
"anchor-markdown-header": "^0.6.0",
"htmlparser2": "^7.2.0",
"minimist": "^1.2.6",
"underscore": "^1.13.2",
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/readme-emoji-headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
README to test doctoc with emoji-first headers

<!-- START doctoc -->
<!-- END doctoc -->

# 🔴 or 🟡 - At Risk

# 🔄 Still Need Updates

## ⏱ Past-Due Items

# ➡ ETA Changes This Week

# 🚀 Shipped this week

# 🛠 Availability repair items

# 🎟 Support Tickets

# 🔬 Team-by-team Breakdown: Hello
22 changes: 22 additions & 0 deletions test/transform-weird-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,25 @@ test('\nnameless table headers', function (t) {
t.end()
})

test('\nemoji-first header names', function (t) {
var content = require('fs').readFileSync(__dirname + '/fixtures/readme-emoji-headers.md', 'utf8');
var headers = transform(content);

t.same(
headers.toc.split('\n')
, [ '',
'- [🔴 or 🟡 - At Risk](#-or----at-risk)',
'- [🔄 Still Need Updates](#-still-need-updates)',
' - [⏱ Past-Due Items](#-past-due-items)',
'- [➡ ETA Changes This Week](#-eta-changes-this-week)',
'- [🚀 Shipped this week](#-shipped-this-week)',
'- [🛠 Availability repair items](#-availability-repair-items)',
'- [🎟 Support Tickets](#-support-tickets)',
'- [🔬 Team-by-team Breakdown: Hello](#-team-by-team-breakdown-hello)',
'' ]
, 'generates a correct toc when readme has emojis as the first character for headings'
)

t.end()
})

0 comments on commit bb82960

Please sign in to comment.