Skip to content

Commit

Permalink
Merge pull request #21 from jakeboone02/issue-20
Browse files Browse the repository at this point in the history
Add support for unicode fraction slash
  • Loading branch information
jakeboone02 authored Aug 23, 2021
2 parents d83c72f + 2b1e648 commit e2d98ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ it('works', () => {
expect(numericQuantity('2 \u2155')).toBe(2.2); // 2 1/5
// Mixed unicode vulgar fraction - no space
expect(numericQuantity('2\u2155')).toBe(2.2); // 2 1/5
// Unicode fraction slash
expect(numericQuantity('1⁄2')).toBe(0.5);
expect(numericQuantity('2 1⁄2')).toBe(2.5);
});
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function numericQuantity(qty: string) {
vulgarFractionsRegex,
(_m, vf: keyof typeof VulgarFraction) => ` ${VulgarFraction[vf]}`
)
.replace(//g, '/')
.trim();

/**
Expand Down

0 comments on commit e2d98ca

Please sign in to comment.