2323
2424import { AbstractWrapper } from '../../core/Tree/Wrapper.js' ;
2525import { Node , PropertyList } from '../../core/Tree/Node.js' ;
26- import { MmlNode , TextNode , AbstractMmlNode , AttributeList } from '../../core/MmlTree/MmlNode.js' ;
26+ import { MmlNode , TextNode , AbstractMmlNode , AttributeList , indentAttributes } from '../../core/MmlTree/MmlNode.js' ;
2727import { MmlMo } from '../../core/MmlTree/MmlNodes/mo.js' ;
2828import { Property } from '../../core/Tree/Node.js' ;
2929import { OptionList } from '../../util/Options.js' ;
@@ -291,7 +291,11 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
291291 this . getScale ( ) ;
292292 this . getSpace ( ) ;
293293 this . childNodes = node . childNodes . map ( ( child : Node ) => {
294- return this . wrap ( child as MmlNode ) ;
294+ const wrapped = this . wrap ( child as MmlNode ) ;
295+ if ( wrapped . bbox . pwidth ) {
296+ this . bbox . pwidth = BBox . fullWidth ;
297+ }
298+ return wrapped ;
295299 } ) ;
296300 }
297301
@@ -574,6 +578,7 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
574578 this . handleColor ( ) ;
575579 this . handleSpace ( ) ;
576580 this . handleAttributes ( ) ;
581+ this . handlePWidth ( ) ;
577582 return chtml ;
578583 }
579584
@@ -685,7 +690,8 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
685690 const defaults = attributes . getAllDefaults ( ) ;
686691 const skip = CHTMLWrapper . skipAttributes ;
687692 for ( const name of attributes . getExplicitNames ( ) ) {
688- if ( skip [ name ] === false || ( ! ( name in defaults ) && ! skip [ name ] && ! this . adaptor . hasAttribute ( this . chtml , name ) ) ) {
693+ if ( skip [ name ] === false || ( ! ( name in defaults ) && ! skip [ name ] &&
694+ ! this . adaptor . hasAttribute ( this . chtml , name ) ) ) {
689695 this . adaptor . setAttribute ( this . chtml , name , attributes . getExplicit ( name ) as string ) ;
690696 }
691697 }
@@ -694,6 +700,19 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
694700 }
695701 }
696702
703+ /*
704+ * Handle the attributes needed for percentage widths
705+ */
706+ protected handlePWidth ( ) {
707+ if ( this . bbox . pwidth ) {
708+ if ( this . bbox . pwidth === BBox . fullWidth ) {
709+ this . adaptor . setAttribute ( this . chtml , 'width' , 'full' ) ;
710+ } else {
711+ this . adaptor . setStyle ( this . chtml , 'width' , this . bbox . pwidth ) ;
712+ }
713+ }
714+ }
715+
697716 /*******************************************************************/
698717
699718 /*
@@ -742,6 +761,42 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
742761 return this . stretch . dir !== DIRECTION . None ;
743762 }
744763
764+ /*
765+ * @return {[string, number] } The alignment and indentation shift for the expression
766+ */
767+ protected getAlignShift ( ) {
768+ let { indentalign, indentshift, indentalignfirst, indentshiftfirst} =
769+ this . node . attributes . getList ( ...indentAttributes ) as StringMap ;
770+ if ( indentalignfirst !== 'indentalign' ) {
771+ indentalign = indentalignfirst ;
772+ }
773+ if ( indentalign === 'auto' ) {
774+ indentalign = 'center' ;
775+ }
776+ if ( indentshiftfirst !== 'indentshift' ) {
777+ indentshift = indentshiftfirst ;
778+ }
779+ if ( indentshift === 'auto' ) {
780+ indentshift = '0' ;
781+ }
782+ const shift = this . length2em ( indentshift , this . metrics . containerWidth ) ;
783+ return [ indentalign , shift ] as [ string , number ] ;
784+ }
785+
786+ /*
787+ * @param {N } chtml The HTML node whose indentation is to be adjusted
788+ * @param {string } align The alignment for the node
789+ * @param {number } shift The indent (positive or negative) for the node
790+ */
791+ protected setIndent ( chtml : N , align : string , shift : number ) {
792+ if ( align === 'center' || align === 'left' ) {
793+ this . adaptor . setStyle ( chtml , 'margin-left' , this . em ( shift ) ) ;
794+ }
795+ if ( align === 'center' || align === 'right' ) {
796+ this . adaptor . setStyle ( chtml , 'margin-right' , this . em ( - shift ) ) ;
797+ }
798+ }
799+
745800 /*******************************************************************/
746801 /*
747802 * For debugging
0 commit comments