Skip to content

Commit 2b1e648

Browse files
committed
Add support for unicode fraction slash
1 parent d83c72f commit 2b1e648

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@ it('works', () => {
6868
expect(numericQuantity('2 \u2155')).toBe(2.2); // 2 1/5
6969
// Mixed unicode vulgar fraction - no space
7070
expect(numericQuantity('2\u2155')).toBe(2.2); // 2 1/5
71+
// Unicode fraction slash
72+
expect(numericQuantity('1⁄2')).toBe(0.5);
73+
expect(numericQuantity('2 1⁄2')).toBe(2.5);
7174
});

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function numericQuantity(qty: string) {
3535
vulgarFractionsRegex,
3636
(_m, vf: keyof typeof VulgarFraction) => ` ${VulgarFraction[vf]}`
3737
)
38+
.replace(//g, '/')
3839
.trim();
3940

4041
/**

0 commit comments

Comments
 (0)