Skip to content

Commit 111cbf8

Browse files
committed
more tests and made the tests less expensive
1 parent d31c526 commit 111cbf8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/steps/rewrite-icons.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ function createIcon(value) {
3333
return h('span', { className: ['icon', `icon-${name}`] });
3434
}
3535

36+
// Helper function to check if a character is a digit
37+
function isDigit(char) {
38+
return char >= '0' && char <= '9';
39+
}
40+
3641
/**
3742
* Rewrite :icons:
3843
*
@@ -70,7 +75,8 @@ export default function rewrite({ content }) {
7075
: '';
7176

7277
// Skip if this looks like part of a pattern
73-
if (/[\d:T]/.test(beforeChar) || /[\d:]/.test(afterChar)) {
78+
if (beforeChar === ':' || beforeChar === 'T' || isDigit(beforeChar)
79+
|| afterChar === ':' || isDigit(afterChar)) {
7480
return idx + 1;
7581
}
7682

test/fixtures/content/icons-ignored.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ <h1 id="icons">Icons</h1>
2121
<p>test:2: should also be ignored</p>
2222
<p>x1:icon: should be ignored</p>
2323
<p>:icon:2 should be ignored</p>
24+
<p>00:00:00</p>
2425
</div>
2526
</main>

test/fixtures/content/icons-ignored.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ test:2: should also be ignored
4141
x1:icon: should be ignored
4242

4343
:icon:2 should be ignored
44+
45+
00:00:00

0 commit comments

Comments
 (0)