Skip to content

Commit

Permalink
fix: rangeless multi chars highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Jan 22, 2024
1 parent 7a69799 commit adb952c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@ export default function rehypePrettyCode(
chars: string;
charsIdAndOrRange: string;
};
const [range, id] = charsIdAndOrRange.split('#');
charsList.push(chars);
range && charsListNumbers.push(rangeParser(range));
id && charsListIdMap.set(chars, id);
if (charsIdAndOrRange === '') {
charsListNumbers.push([]);
} else {
const [range, id] = charsIdAndOrRange.split('#');
range && charsListNumbers.push(rangeParser(range));
id && charsListIdMap.set(chars, id);
}
});
}

Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/highlightedMultipleCharsRange.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ const strLen = getStringLength('str');

const anotherStrLen = getStringLength('anotherStr');
```

/getStringLength/ /str/2,3

```js /getStringLength/ /str/2,3
const getStringLength = (str) => str.length;

const strLen = getStringLength('str');

const anotherStrLen = getStringLength('anotherStr');
```

0 comments on commit adb952c

Please sign in to comment.