Skip to content

Commit db424ed

Browse files
feat: Add ghost repetitions #44 (#56)
Closes #44
1 parent 2e173d0 commit db424ed

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

anchor-markdown-header.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ function basicGhostId(text) {
7676
;
7777
}
7878

79-
function getGhostId(text) {
79+
function getGhostId(text, repetition) {
8080
text = basicGhostId(text);
8181

82-
// Repetitions not supported
82+
// If no repetition, or if the repetition is 0 then ignore. Otherwise append '-' and the number.
83+
if (repetition) {
84+
text += '-' + repetition;
85+
}
8386

8487
return text;
8588
}

test/anchor-markdown-header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test('\ngenerating anchor in ghost mode', function (t) {
9090

9191
[ [ 'intro', null, '#intro' ]
9292
, [ 'intro', 0, '#intro' ]
93-
, [ 'repetitions not supported', 1, '#repetitionsnotsupported' ]
93+
, [ 'intro', 1, '#intro-1' ]
9494
, [ 'mineflayer.windows.Window (base class)', null, '#mineflayerwindowswindowbaseclass']
9595
, [ 'window.findInventoryItem(itemType, metadata, [notFull])', null, '#windowfindinventoryitemitemtypemetadatanotfull' ]
9696
, [ 'furnace "updateSlot" (oldItem, newItem)', null, '#furnaceupdateslotolditemnewitem' ]

0 commit comments

Comments
 (0)