feat: add especial symbols to mi tag implementation
This commit is contained in:
parent
0cb16d14b5
commit
83dc582946
|
@ -1,4 +1,6 @@
|
||||||
import { MathMLTag } from './MathMLTag';
|
import { MathMLTag } from './MathMLTag';
|
||||||
|
import { allMathSymbolsByChar } from '../../../../syntax/allMathSymbolsByChar';
|
||||||
|
import { allMathSymbolsByGlyph } from '../../../../syntax/allMathSymbolsByGlyph';
|
||||||
|
|
||||||
export class MI extends MathMLTag {
|
export class MI extends MathMLTag {
|
||||||
constructor(value: string, attributes: Record<string, string>, children: MathMLTag[]) {
|
constructor(value: string, attributes: Record<string, string>, children: MathMLTag[]) {
|
||||||
|
@ -7,6 +9,33 @@ export class MI extends MathMLTag {
|
||||||
|
|
||||||
convert(): string {
|
convert(): string {
|
||||||
const normalizedValue = this._normalizeWhiteSpaces(this._value);
|
const normalizedValue = this._normalizeWhiteSpaces(this._value);
|
||||||
return normalizedValue.trim();
|
if (normalizedValue === ' ') return Character.apply(normalizedValue);
|
||||||
|
|
||||||
|
const trimmedValue = normalizedValue.trim();
|
||||||
|
return Character.apply(trimmedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Character {
|
||||||
|
private _value: string;
|
||||||
|
|
||||||
|
constructor(value: string) {
|
||||||
|
this._value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static apply(value: string): string {
|
||||||
|
return new Character(value)._apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _apply(): string {
|
||||||
|
return this._findByCharacter() || this._findByGlyph() || this._value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _findByCharacter(): string | undefined {
|
||||||
|
return allMathSymbolsByChar[this._value];
|
||||||
|
}
|
||||||
|
|
||||||
|
private _findByGlyph(): string | undefined {
|
||||||
|
return allMathSymbolsByGlyph[this._value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue