Implemented merror tag use cases
This commit is contained in:
parent
37435d2826
commit
64ebf97a88
@ -1045,4 +1045,24 @@ describe('#convert', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('given math string with merror tag', () => {
|
||||
test('convert merror placing its content inside \\color{red}', () => {
|
||||
const mathml = `
|
||||
<root>
|
||||
<math>
|
||||
<merror>
|
||||
<mi>2</mi>
|
||||
<mo>+</mo>
|
||||
<mi>2</mi>
|
||||
</merror>
|
||||
</math>
|
||||
</root>
|
||||
`;
|
||||
|
||||
const result = MathMLToLaTeX.convert(mathml);
|
||||
|
||||
expect(result).toBe('\\color{red}{2 + 2}');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
GenericContentWrapperTag,
|
||||
MAction,
|
||||
MEnclose,
|
||||
MError,
|
||||
} from './mathml-tags';
|
||||
|
||||
export class Dispatcher {
|
||||
@ -51,6 +52,8 @@ export class Dispatcher {
|
||||
return new MAction(this._value, this._attributes, this._children);
|
||||
case 'menclose':
|
||||
return new MEnclose(this._value, this._attributes, this._children);
|
||||
case 'merror':
|
||||
return new MError(this._value, this._attributes, this._children);
|
||||
case 'mrow':
|
||||
case 'mpadded':
|
||||
return new GenericContentWrapperTag(this._name, this._value, this._attributes, this._children);
|
||||
|
@ -0,0 +1,11 @@
|
||||
import { MathMLTag } from './MathMLTag';
|
||||
|
||||
export class MError extends MathMLTag {
|
||||
constructor(value: string, attributes: Record<string, string>, children: MathMLTag[]) {
|
||||
super('merror', value, attributes, children);
|
||||
}
|
||||
|
||||
convert(): string {
|
||||
return `\\color{red}{${this._mapChildrenToLaTeX().join(' ')}}`;
|
||||
}
|
||||
}
|
@ -11,3 +11,4 @@ export { MRoot } from './MRoot';
|
||||
export { GenericContentWrapperTag } from './GenericContentWrapperTag';
|
||||
export { MAction } from './MAction';
|
||||
export { MEnclose } from './MEnclose';
|
||||
export { MError } from './MError';
|
||||
|
Loading…
Reference in New Issue
Block a user