Forum


Replies: 4   Views: 4491
Embedhtml(): how to style bold text when strictwordstyles = true
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by shroom  · 21-12-2015 - 15:01

I figured out how to accomplish what I needed by modifying HTML2WordML.inc:

case 'sub':
case 'sup':
case 'span':
   if ($nodo['nodeName'] == 'sub') {self::$openScript = 'subscript';}
   if ($nodo['nodeName'] == 'sup') {self::$openScript = 'superscript';}
   self::$WordML .= $this->closePreviousTags($depth, $nodo['nodeName']);
   if(!empty($nodo['attributes']['class'][0])){
      self::$WordML .= '<w:rPr><w:rStyle w:val="'.$nodo['attributes']['class'][0].'"/></w:rPr>';
   }
   self::$openTags[$depth] = $nodo['nodeName'];
   break;
case '#text':

This allows me to assign character classes to <sup>s, <sub>s, and <span>s even  when strictWordStyles = true.  It works well except that the class is not applied if the <span> or <sup> is the first element in a <p>.  It's probably something missing in the WordML I am inserting...  My workaround is to insert a zero-length-space (&#8203;) preceding <span>s and <sup>s.  Then it works fine.

I have one more issue I need to handle concerning how to embed footnotes in strings containing HTML.  I'll post about it later.

Thanks.