MCPcopy Index your code
hub / github.com/TruthHun/BookStack / parseSymbol

Method parseSymbol

static/katex/katex.mjs:15750–15886  ·  view source on GitHub ↗

* Parse a single symbol out of the string. Here, we handle single character * symbols and special functions like verbatim

()

Source from the content-addressed store, hash-verified

15748
15749
15750 parseSymbol() {
15751 const nucleus = this.nextToken;
15752 let text = nucleus.text;
15753
15754 if (/^\\verb[^a-zA-Z]/.test(text)) {
15755 this.consume();
15756 let arg = text.slice(5);
15757 const star = arg.charAt(0) === "*";
15758
15759 if (star) {
15760 arg = arg.slice(1);
15761 } // Lexer's tokenRegex is constructed to always have matching
15762 // first/last characters.
15763
15764
15765 if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) {
15766 throw new ParseError(`\\verb assertion failed --
15767 please report what input caused this bug`);
15768 }
15769
15770 arg = arg.slice(1, -1); // remove first and last char
15771
15772 return {
15773 type: "verb",
15774 mode: "text",
15775 body: arg,
15776 star
15777 };
15778 } // At this point, we should have a symbol, possibly with accents.
15779 // First expand any accented base symbol according to unicodeSymbols.
15780
15781
15782 if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) {
15783 // This behavior is not strict (XeTeX-compatible) in math mode.
15784 if (this.settings.strict && this.mode === "math") {
15785 this.settings.reportNonstrict("unicodeTextInMathMode", `Accented Unicode text character "${text[0]}" used in ` + `math mode`, nucleus);
15786 }
15787
15788 text = unicodeSymbols[text[0]] + text.substr(1);
15789 } // Strip off any combining characters
15790
15791
15792 const match = combiningDiacriticalMarksEndRegex.exec(text);
15793
15794 if (match) {
15795 text = text.substring(0, match.index);
15796
15797 if (text === 'i') {
15798 text = '\u0131'; // dotless i, in math and text mode
15799 } else if (text === 'j') {
15800 text = '\u0237'; // dotless j, in math and text mode
15801 }
15802 } // Recognize base symbol
15803
15804
15805 let symbol;
15806
15807 if (symbols[this.mode][text]) {

Callers 3

parseGroupMethod · 0.95
katex.jsFile · 0.80
katex.min.jsFile · 0.80

Calls 4

consumeMethod · 0.95
reportNonstrictMethod · 0.80
supportedCodepointFunction · 0.70
rangeMethod · 0.45

Tested by

no test coverage detected