Add @flow to unicodeRegexes and change to ES6 exports.

This commit is contained in:
Ashish Myles
2017-09-06 23:29:17 -04:00
committed by Ashish Myles
parent 588f5a1ee6
commit d46ca811c1
2 changed files with 6 additions and 10 deletions

View File

@@ -7,7 +7,7 @@
*
* Similar functions for working with MathML nodes exist in mathMLTree.js.
*/
import unicodeRegexes from "./unicodeRegexes";
import {cjkRegex, hangulRegex} from "./unicodeRegexes";
import utils from "./utils";
/**
@@ -222,11 +222,11 @@ class symbolNode {
// fonts to use. This allows us to render these characters with a serif
// font in situations where the browser would either default to a sans serif
// or render a placeholder character.
if (unicodeRegexes.cjkRegex.test(value)) {
if (cjkRegex.test(value)) {
// I couldn't find any fonts that contained Hangul as well as all of
// the other characters we wanted to test there for it gets its own
// CSS class.
if (unicodeRegexes.hangulRegex.test(value)) {
if (hangulRegex.test(value)) {
this.classes.push('hangul_fallback');
} else {
this.classes.push('cjk_fallback');

View File

@@ -1,4 +1,5 @@
const hangulRegex = /[\uAC00-\uD7AF]/;
// @flow
export const hangulRegex = /[\uAC00-\uD7AF]/;
// This regex combines
// - CJK symbols and punctuation: [\u3000-\u303F]
@@ -8,10 +9,5 @@ const hangulRegex = /[\uAC00-\uD7AF]/;
// - Hangul syllables: [\uAC00-\uD7AF]
// - Fullwidth punctuation: [\uFF00-\uFF60]
// Notably missing are halfwidth Katakana and Romanji glyphs.
const cjkRegex =
export const cjkRegex =
/[\u3000-\u30FF\u4E00-\u9FAF\uAC00-\uD7AF\uFF00-\uFF60]/;
module.exports = {
cjkRegex: cjkRegex,
hangulRegex: hangulRegex,
};