问题
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">•</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 •
; or •
.
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