diff --git a/src/converters/mathml-interfaces-to-latex/mathml-tag-to-latex/mathml-tags/MFenced.ts b/src/converters/mathml-interfaces-to-latex/mathml-tag-to-latex/mathml-tags/MFenced.ts index 9ddc7a4..a76ada4 100755 --- a/src/converters/mathml-interfaces-to-latex/mathml-tag-to-latex/mathml-tags/MFenced.ts +++ b/src/converters/mathml-interfaces-to-latex/mathml-tag-to-latex/mathml-tags/MFenced.ts @@ -3,21 +3,37 @@ import { GenericWrapper } from '../../../../utils/wrappers'; import { JoinWithManySeparators } from '../../../../utils'; export class MFenced extends MathMLTag { - private _wrapper: GenericWrapper; - private _separators: string[]; + private readonly _open: string; + private readonly _close: string; + private readonly _separators: string[]; constructor(value: string, attributes: Record, children: MathMLTag[]) { super('mfenced', value, attributes, children); - const open: string = this._attributes.open || '('; - const close: string = this._attributes.close || ')'; - this._wrapper = new GenericWrapper(open, close); - + this._open = this._attributes.open || '('; + this._close = this._attributes.close || ')'; this._separators = Array.from(this._attributes.separators || ''); } convert(): string { - const withoutWrapper = JoinWithManySeparators.join(this._mapChildrenToLaTeX(), this._separators); - return this._wrapper.wrap(withoutWrapper); + return new Vector(this._open, this._close, this._separators).apply(this._mapChildrenToLaTeX()); + } +} + +class Vector { + private readonly _open: string; + private readonly _close: string; + private readonly _separators: string[]; + + constructor(open: string, close: string, separators: string[]) { + this._open = open; + this._close = close; + this._separators = separators; + } + + apply(latexContents: string[]): string { + const contentWithoutWrapper = JoinWithManySeparators.join(latexContents, this._separators); + + return new GenericWrapper(this._open, this._close).wrap(contentWithoutWrapper); } }