Skip to content

Commit

Permalink
Make \\| work
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Apr 6, 2022
1 parent 8b69495 commit 1742709
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Lang = Parsimmon.createLanguage({
.thru(makeNode('UnaryMacro')),

NullaryMacro: () =>
Parsimmon.regexp(/\\[a-zA-Z]+/)
Parsimmon.alt(Parsimmon.regexp(/\\[a-zA-Z]+/), Parsimmon.regexp(/\\\|/))
.map((x) => {
return {
macro: x,
Expand Down
2 changes: 1 addition & 1 deletion lib/symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function preprocess(obj) {
res[key] = obj[key];
} else if (/^\\not(.*)$/.test(key)) {
res[key] = obj[key];
} else if (/^[_^](.*)$/.test(key)) {
} else if (/^[_^](.*)$/.test(key) || key === '\\|') {
res[key] = obj[key];
} else {
throw new Error(`Symbol table does not allow this key: ${key}`);
Expand Down
4 changes: 4 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ const testCases = [
tex: '\\mathbb\\alpha',
out: '\\mathbb\\alpha',
},
{
tex: '\\|',
out: '‖',
},
];

describe('convertText', () => {
Expand Down

0 comments on commit 1742709

Please sign in to comment.