Inserting a bullet point and styling to [onshow.] entires in openTBS

筅森魡賤 提交于 2019-12-13 21:23:36

问题


I was wondering if there was a way to pass through a bullet point and a basic CSS colour styling for the bullet point via the variable that gets applied via onshow. IE

$string = '<span style="color:red">&#149;</span> The rest of the string';
$TBS -> VarRef['bulletPoint'] = $string;

And then in the docx template have

[onshow.bulletPoint] which gets replaced with

• The rest of the string

But with the bullet point red in this case.


回答1:


For the bullet, you can use the UTF8 common character. OpenXML seems to not recognizes all the HTML special chards such as &#149; or &bull;.

So the remaining problem is to insert a string including a style change. Since in OpenXML styles cannot be applied inside an XML entity (such as in XML), then you have to operate on the entire entity that contains your string. It must be a which represent a portion of text in DOCX (assuming your document is a DOCX).

$string = "
      <w:r>
        <w:rPr>
          <w:color w:val="FF0000"/>
        </w:rPr>
        <w:t>•</w:t>
      </w:r>
      <w:r>
        <w:t xml:space="preserve"> The rest of the string</w:t>
      </w:r>";
$TBS->VarRef['bulletPoint'] = $string;

DOCX :

[onshow.bulletPoint;strconv=no;enlarge=w:r]

Parameter strconv=no enables you to not convert the XML. Parameter enlarge=w:r enables you extend the bounds of the TBS field. This may
enwrap some other piece of text that may be placed in the same <w:r> entity.



来源:https://stackoverflow.com/questions/18754590/inserting-a-bullet-point-and-styling-to-onshow-entires-in-opentbs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!