Skip to content

Commit 9e25637

Browse files
committed
Merge branch 'origin/verb_package' into beta.2
2 parents 0165aa1 + 080ded3 commit 9e25637

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

lib/TeX-lab.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../mathjax3/input/tex/newcommand/NewcommandConfiguration.js';
1717
import '../mathjax3/input/tex/braket/BraketConfiguration.js';
1818
import '../mathjax3/input/tex/mhchem/MhchemConfiguration.js';
1919
import '../mathjax3/input/tex/physics/PhysicsConfiguration.js';
20+
import '../mathjax3/input/tex/verb/VerbConfiguration.js';
2021

2122
const jax = {
2223
TeX: new TeX(),
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*************************************************************
2+
*
3+
* Copyright (c) 2018 The MathJax Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
/**
20+
* @fileoverview Configuration file for the verb package.
21+
*
22+
* @author [email protected] (Volker Sorge)
23+
*/
24+
25+
import {Configuration} from '../Configuration.js';
26+
import {TexConstant} from '../TexConstants.js';
27+
import TexParser from '../TexParser.js';
28+
import {CommandMap} from '../SymbolMap.js';
29+
import {ParseMethod} from '../Types.js';
30+
import TexError from '../TexError.js';
31+
32+
33+
// Namespace
34+
export let VerbMethods: Record<string, ParseMethod> = {};
35+
36+
37+
/**
38+
* Implements the verbatim notation \verb|...|.
39+
* @param {TexParser} parser The current tex parser.
40+
* @param {string} name The name of the calling macro.
41+
*/
42+
VerbMethods.Verb = function(parser: TexParser, name: string, notation: string) {
43+
const c = parser.GetNext();
44+
const start = ++parser.i;
45+
if (c === '' ) {
46+
throw new TexError('MissingArgFor', 'Missing argument for %1', name);
47+
}
48+
while (parser.i < parser.string.length && parser.string.charAt(parser.i) !== c) {
49+
parser.i++;
50+
}
51+
if (parser.i === parser.string.length) {
52+
throw new TexError('NoClosingDelim',
53+
'Can\'t find closing delimiter for %1', parser.currentCS);
54+
}
55+
const text = parser.string.slice(start, parser.i).replace(/ /g, '\u00A0');
56+
parser.i++;
57+
parser.Push(parser.create('token', 'mtext',
58+
{mathvariant: TexConstant.Variant.MONOSPACE},
59+
text));
60+
};
61+
62+
63+
new CommandMap('verb', {verb: 'Verb'}, VerbMethods);
64+
65+
66+
export const VerbConfiguration = Configuration.create(
67+
'verb', {handler: {macro: ['verb']}}
68+
);

0 commit comments

Comments
 (0)