Skip to content

Commit

Permalink
Remove link URLs from anchors in GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornella committed Sep 23, 2020
1 parent ee7536f commit ff75574
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions anchor-markdown-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function basicGithubId(text) {
return text.replace(/ /g,'-')
// escape codes
.replace(/%([abcdef]|\d){2,2}/ig, '')
// link URLs are removed
.replace(/\[(.*)\]\(.*\)/, '$1')
// single chars that are removed
.replace(/[\/?!:\[\]`.,()*"';{}+=<>~\$|#@&–—]/g,'')
// CJK punctuations that are removed
Expand Down
1 change: 1 addition & 0 deletions test/anchor-markdown-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ test('\ngenerating anchor in github mode', function (t) {
, [ '👷🏼‍♀️ Maintenance', null, '#%EF%B8%8F-maintenance']
, [ 'Alarm clock ⏰', null, '#alarm-clock-']
, [ 'Apple Watch ⌚️', null, '#apple-watch-%EF%B8%8F']
, [ 'Remove Markdown links [`EventEmitter`](http://nodejs.org/api/events.html)', null, '#remove-markdown-links-eventemitter']
].forEach(function (x) { check(x[0], x[1], x[2]) });
t.end();
})
Expand Down

0 comments on commit ff75574

Please sign in to comment.