diff --git a/src/symbols.js b/src/symbols.js index 0e47f1a3..192ed744 100644 --- a/src/symbols.js +++ b/src/symbols.js @@ -21,12 +21,16 @@ module.exports = { text: {}, }; -function defineSymbol(mode, font, group, replace, name) { +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { module.exports[mode][name] = { font: font, group: group, replace: replace, }; + + if (acceptUnicodeChar) { + module.exports[mode][replace] = module.exports[mode][name]; + } } // Some abbreviations for commonly used strings. @@ -413,53 +417,53 @@ defineSymbol(math, main, textord, "\u2220", "\\angle"); defineSymbol(math, main, textord, "\u221e", "\\infty"); defineSymbol(math, main, textord, "\u2032", "\\prime"); defineSymbol(math, main, textord, "\u25b3", "\\triangle"); -defineSymbol(math, main, textord, "\u0393", "\\Gamma"); -defineSymbol(math, main, textord, "\u0394", "\\Delta"); -defineSymbol(math, main, textord, "\u0398", "\\Theta"); -defineSymbol(math, main, textord, "\u039b", "\\Lambda"); -defineSymbol(math, main, textord, "\u039e", "\\Xi"); -defineSymbol(math, main, textord, "\u03a0", "\\Pi"); -defineSymbol(math, main, textord, "\u03a3", "\\Sigma"); -defineSymbol(math, main, textord, "\u03a5", "\\Upsilon"); -defineSymbol(math, main, textord, "\u03a6", "\\Phi"); -defineSymbol(math, main, textord, "\u03a8", "\\Psi"); -defineSymbol(math, main, textord, "\u03a9", "\\Omega"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); defineSymbol(math, main, textord, "\u00ac", "\\neg"); defineSymbol(math, main, textord, "\u00ac", "\\lnot"); defineSymbol(math, main, textord, "\u22a4", "\\top"); defineSymbol(math, main, textord, "\u22a5", "\\bot"); defineSymbol(math, main, textord, "\u2205", "\\emptyset"); defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); -defineSymbol(math, main, mathord, "\u03b1", "\\alpha"); -defineSymbol(math, main, mathord, "\u03b2", "\\beta"); -defineSymbol(math, main, mathord, "\u03b3", "\\gamma"); -defineSymbol(math, main, mathord, "\u03b4", "\\delta"); -defineSymbol(math, main, mathord, "\u03f5", "\\epsilon"); -defineSymbol(math, main, mathord, "\u03b6", "\\zeta"); -defineSymbol(math, main, mathord, "\u03b7", "\\eta"); -defineSymbol(math, main, mathord, "\u03b8", "\\theta"); -defineSymbol(math, main, mathord, "\u03b9", "\\iota"); -defineSymbol(math, main, mathord, "\u03ba", "\\kappa"); -defineSymbol(math, main, mathord, "\u03bb", "\\lambda"); -defineSymbol(math, main, mathord, "\u03bc", "\\mu"); -defineSymbol(math, main, mathord, "\u03bd", "\\nu"); -defineSymbol(math, main, mathord, "\u03be", "\\xi"); -defineSymbol(math, main, mathord, "o", "\\omicron"); -defineSymbol(math, main, mathord, "\u03c0", "\\pi"); -defineSymbol(math, main, mathord, "\u03c1", "\\rho"); -defineSymbol(math, main, mathord, "\u03c3", "\\sigma"); -defineSymbol(math, main, mathord, "\u03c4", "\\tau"); -defineSymbol(math, main, mathord, "\u03c5", "\\upsilon"); -defineSymbol(math, main, mathord, "\u03d5", "\\phi"); -defineSymbol(math, main, mathord, "\u03c7", "\\chi"); -defineSymbol(math, main, mathord, "\u03c8", "\\psi"); -defineSymbol(math, main, mathord, "\u03c9", "\\omega"); -defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon"); -defineSymbol(math, main, mathord, "\u03d1", "\\vartheta"); -defineSymbol(math, main, mathord, "\u03d6", "\\varpi"); -defineSymbol(math, main, mathord, "\u03f1", "\\varrho"); -defineSymbol(math, main, mathord, "\u03c2", "\\varsigma"); -defineSymbol(math, main, mathord, "\u03c6", "\\varphi"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); defineSymbol(math, main, bin, "\u2217", "*"); defineSymbol(math, main, bin, "+", "+"); defineSymbol(math, main, bin, "\u2212", "-"); diff --git a/test/katex-spec.js b/test/katex-spec.js index f44a808a..da2c81d7 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -2332,3 +2332,13 @@ describe("A parser taking String objects", function() { expect(new String("\\frac 1 2")).toParseLike("\\frac 1 2"); }); }); + +describe("Unicode", function() { + it("should parse all lower case Greek letters", function() { + expect("αβγδεϵζηθϑικλμνξοπϖρϱςστυφϕχψω").toParse(); + }); + + it("should parse 'ΓΔΘΞΠΣΦΨΩ'", function() { + expect("ΓΔΘΞΠΣΦΨΩ").toParse(); + }); +}); diff --git a/test/screenshotter/images/GreekUnicode-chrome.png b/test/screenshotter/images/GreekUnicode-chrome.png new file mode 100644 index 00000000..e155bf64 Binary files /dev/null and b/test/screenshotter/images/GreekUnicode-chrome.png differ diff --git a/test/screenshotter/images/GreekUnicode-firefox.png b/test/screenshotter/images/GreekUnicode-firefox.png new file mode 100644 index 00000000..a8830d9e Binary files /dev/null and b/test/screenshotter/images/GreekUnicode-firefox.png differ diff --git a/test/screenshotter/ss_data.yaml b/test/screenshotter/ss_data.yaml index bb2b195e..32c1fe9c 100644 --- a/test/screenshotter/ss_data.yaml +++ b/test/screenshotter/ss_data.yaml @@ -91,6 +91,7 @@ Gathered: | y = \sum_{i=1}^n i \end{array} GreekLetters: \alpha\beta\gamma\omega +GreekUnicode: \frac{αβγδεϵζηθϑικλμνξοπϖρϱςστυφϕχψω}{ΓΔΘΞΠΣΦΨΩ\mathbf{Ω}\mathbf{\Omega}} GroupMacros: macros: \startExp: e^\bgroup