-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feature: document lxml element of proxy classes for advanced users #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, is there anything I can do to help this along? <w:r>
<w:rPr>
<w:rFonts w:ascii="HelveticaNeueLT Com 45 Lt" w:cs="Times New Roman" w:eastAsia="Calibri" w:hAnsi="HelveticaNeueLT Com 45 Lt"/>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
<w:shd w:fill="00FF00" w:val="clear"/> <=== THE BIT I WANT
</w:rPr>
<w:t>Public Building/Cultural</w:t>
</w:r> Handling just this bit to pull out the shading is fine, but parsing the whole doc seems way too much like hard work! UpdateI got around this in a bit of a hacky way with this:
|
You can access this element with the >>> from docx.oxml.shared import qn
>>> assert isinstance(Run, run)
>>> rPr = run._r.rPr
>>> shd = rPr.find(qn('w:shd')) # returns the shd child element or None if not present
>>> shd.get(qn('w:fill'))
'00FF00'
>>> shd.get(qn('w:val'))
'clear' |
I'm making use of the underlying |
I added the shading element in my merge request. Have it functioning for table cells. Should be easily added to runs. |
@progamniac please ask support questions on StackOverflow using the |
Feature/add comments on run level
Proxy classes such as Document, Paragraph, and Table each hold a private reference to the lxml element they correspond to,
<w:document>
,<w:p>
, and<w:tbl>
respectively. With these elements, advanced users can call the underlying lxml API directly to develop customized solutions the existing API does not yet support.Add documentation so advanced users can readily access these elements without consulting the source code.
The text was updated successfully, but these errors were encountered: