6.2 Eliminate End Script Marks

The following takes care of end-scripts that semantically can be merged into other end markers.

<..eliminate baseline script marks..>
 <xsl:template match="span[
    (@class = ’end-script’)
    and
    ancestor::* [ following-sibling::* [
                          not( @class = ’content-less’ )
                       ]
                ][1]
            / following-sibling::* [
                          not( @class = ’content-less’ )
                      ][1]
            / self::*
     [
        (@class = ’end-math’)
        or
        (@class = ’end-script’)
        or
        (@class = ’end-root’)
        or
        (@class = ’end-stack’)
        or
        (@class = ’mid-stack’)
        or
        (@class = ’end-array’)
        or
         self::td or self::mtd or self::tr or self::mtr
        or
        (@title = ’implicit-baseline’)
     ]
 ]"  >
   <BREAK SIZE="small"/>
 </xsl:template>
-_-_-

The following deals with endscripts before left sides of tensors.

<..eliminate baseline script marks..>+
 <xsl:template match="span[
    (@class = ’end-script’)
    and
     parent::mrow / parent::msub
    and
    ancestor::* [ following-sibling::* ][1]
    / following-sibling::* [ normalize-space(.) != ’’ ][1]
     [
        (self::msub or self::msubsup)
      and
        (normalize-space(child::mrow[
           @class = ’mrow-base’ ]) = ’’)
     ]
 ]"  >
   <BREAK SIZE="small"/>
 </xsl:template>
-_-_-

<..eliminate baseline script marks..>+
 <xsl:template match="span[
    (@class = ’end-script’)
    and
      parent::mrow /parent::*[ self::msup or self::msubsup]
    and
    ancestor::* [ following-sibling::* ][1]
    / following-sibling::* [ normalize-space(.) != ’’ ][1]
     [
        self::msup
      and
        (normalize-space(child::mrow[
           @class = ’mrow-base’ ]) = ’’)
     ]
 ]"  >
   <BREAK SIZE="small"/>
 </xsl:template>
-_-_-
    <span class="end-script" title="speech-extra">  
      <PROS PITCH="-5">  
        <BREAK SIZE="medium"/>  
        <span class="scripts-extra"> baseline </span>  
        <BREAK SIZE="small"/>  
      </PROS>  
    </span>  
  </mrow>  
</msup>  
<span class="tiny-space"/>  
<msup>  
  <mrow class="mrow-base"/>  
  <mrow class="mrow-super">