Skip to content

Commit c143fa6

Browse files
authored
Merge pull request #1365 from mathjax/issue3447
Fix handling of argument to \set and others. (mathjax/MathJax#3447)
2 parents e9765e6 + c98ed35 commit c143fa6

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

testsuite/tests/input/tex/Braket.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,20 @@ describe('Braket', () => {
665665

666666
/********************************************************************************/
667667

668+
it('Braket-braces', () => {
669+
expectTexError('\\braket{')
670+
.toBe('Missing close brace');
671+
});
672+
673+
/********************************************************************************/
674+
675+
it('Braket-braces', () => {
676+
expectTexError('\\braket}')
677+
.toBe('Extra close brace or missing open brace');
678+
});
679+
680+
/********************************************************************************/
681+
668682
});
669683

670684
/**********************************************************************************/

ts/input/tex/braket/BraketMethods.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ import { ParseMethod, ParseResult } from '../Types.js';
2525
import BaseMethods from '../base/BaseMethods.js';
2626
import TexParser from '../TexParser.js';
2727
import { TEXCLASS } from '../../../core/MmlTree/MmlNode.js';
28-
import TexError from '../TexError.js';
2928
import { BraketItem } from './BraketItems.js';
3029

3130
const BraketMethods: { [key: string]: ParseMethod } = {
3231
/**
3332
* Generate a bra-ket expression.
3433
*
3534
* @param {TexParser} parser The current TeX parser.
36-
* @param {string} _name Name of the current control sequence.
35+
* @param {string} name Name of the current control sequence.
3736
* @param {string} open Opening delimiter.
3837
* @param {string} close Closing delimiter.
3938
* @param {boolean} stretchy Is it stretchy.
@@ -42,21 +41,17 @@ const BraketMethods: { [key: string]: ParseMethod } = {
4241
*/
4342
Braket(
4443
parser: TexParser,
45-
_name: string,
44+
name: string,
4645
open: string,
4746
close: string,
4847
stretchy: boolean,
4948
barmax: number,
5049
space: boolean = false
5150
) {
51+
const i = parser.i;
52+
parser.GetArgument(name); // Error if there isn't a proper argument
53+
parser.i = i;
5254
const next = parser.GetNext();
53-
if (next === '') {
54-
throw new TexError(
55-
'MissingArgFor',
56-
'Missing argument for %1',
57-
parser.currentCS
58-
);
59-
}
6055
let single = true;
6156
if (next === '{') {
6257
parser.i++;

0 commit comments

Comments
 (0)