Skip to content

Commit ead8f77

Browse files
authored
fix: icon regex to allow numbers to have a hyphen following as longs as that follows with another character (#693)
1 parent 377d436 commit ead8f77

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

src/steps/rewrite-icons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { h } from 'hastscript';
1414
import { CONTINUE, SKIP, visit } from 'unist-util-visit';
1515

16-
const REGEXP_ICON = /(?<!(?:https?|urn)[^\s]*):(#?[a-z_-]+[a-z\d]*):/gi;
16+
const REGEXP_ICON = /(?<!(?:https?|urn)[^\s]*):(#?[a-z][a-z\d_-]+[a-z\d]):/gi;
1717

1818
/**
1919
* Create a <span> icon element:

test/fixtures/content/icons-ignored.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ <h1 id="icons">Icons</h1>
55
<pre><code>:rocket:</code></pre>
66
<p><a href="https://example.test/:urn:">https://example.test/:urn:</a></p>
77
<p>urn:aaid:sc:VA6C2:ac6066f3-fd1d-4e00-bed3-fa3aa6d981d8</p>
8+
<p>:red-check-mark-:</p>
9+
<p>:be:</p>
810
</div>
9-
</main>
11+
</main>

test/fixtures/content/icons-ignored.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
[https://example.test/:urn:](https://example.test/:urn:)
1010

1111
urn:aaid:sc:VA6C2:ac6066f3-fd1d-4e00-bed3-fa3aa6d981d8
12+
13+
:red-check-mark-:
14+
15+
:be:

test/fixtures/content/icons.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ <h1 id="icons">Icons</h1>
55
<p>Hello <span class="icon icon-red"></span> banner.</p>
66
<p>Hello <span class="icon icon-check"></span> mark.</p>
77
<p>Team<span class="icon icon-rocket"></span>blasting off again.</p>
8+
<p><span class="icon icon-red-check-mark"></span></p>
9+
<p><span class="icon icon-red-check-1"></span></p>
10+
<p><span class="icon icon-red-check-2-mark"></span></p>
811
</div>
9-
</main>
12+
</main>

test/fixtures/content/icons.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ Hello :red: banner.
77
Hello :#check: mark.
88

99
Team:rocket:blasting off again.
10+
11+
:red-check-mark:
12+
13+
:red-check-1:
14+
15+
:red-check-2-mark:

0 commit comments

Comments
 (0)