operator-dictionary.js (1072B)
1 async function fetchOperatorDictionary() { 2 let response = await fetch(`/mathml/support/operator-dictionary.json`); 3 return response.json(); 4 } 5 6 function splitKey(key) { 7 var value = key.split(" ") 8 return { 9 characters: value[0], 10 form: value[1] 11 }; 12 } 13 14 function spaceIndexToLength(index) { 15 // See https://w3c.github.io/mathml-core/#operator-dictionary 16 return ["0", 17 "0.05555555555555555em", 18 "0.1111111111111111em", 19 "0.16666666666666666em", 20 "0.2222222222222222em", 21 "0.2777777777777778em", 22 "0.3333333333333333em", 23 "0.3888888888888889em" 24 ][index]; 25 } 26 27 function defaultPropertyValue(entry, name) { 28 switch (name) { 29 case "lspace": 30 case "rspace": 31 return spaceIndexToLength(entry.hasOwnProperty(name) ? entry[name] : 5); 32 break 33 case "largeop": 34 case "movablelimits": 35 case "stretchy": 36 case "symmetric": 37 case "accent": 38 return entry[name]; 39 default: 40 throw `Unknown property ${name}`; 41 } 42 }