Skip to content

Commit

Permalink
Add support for *{n}{...} in array preamble. (mathjax/MathJax#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Aug 25, 2023
1 parent a662fa7 commit 1a55ab5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ts/input/tex/ColumnParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class ColumnParser {
'<': (state) => state.cend[state.j - 1] = (state.cend[state.j - 1] || '') + this.getBraces(state),
'@': (state) => this.addAt(state, this.getBraces(state)),
'!': (state) => this.addBang(state, this.getBraces(state)),
'*': (state) => this.repeat(state),
//
// Non-standard for math-mode versions
//
Expand Down Expand Up @@ -344,4 +345,20 @@ export class ColumnParser {
cspace[++state.j] = '.5em';
}

/**
* Add a *{n}{...} entry
*
* @param {ColumnState} state The current state of the parser
*/
public repeat(state: ColumnState) {
const num = this.getBraces(state);
const cols = this.getBraces(state);
const n = parseInt(num);
if (String(n) !== num) {
throw new TexError('ColArgNotNum', 'First argument to %1 column specifier must be a number', '*');
}
state.template = new Array(n).fill(cols).join('') + state.template.substr(state.i);
state.i = 0;
}

}

0 comments on commit 1a55ab5

Please sign in to comment.