-
Notifications
You must be signed in to change notification settings - Fork 57
Heading inside complex field has strong applied #188
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
Changes from all commits
f1003f9
581e657
5fca0ea
6c62e0f
d896511
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,58 @@ | |
) | ||
|
||
|
||
from pydocx.openxml.packaging import MainDocumentPart | ||
from pydocx.openxml.packaging import MainDocumentPart, StyleDefinitionsPart | ||
from pydocx.test import DocumentGeneratorTestCase | ||
from pydocx.test.utils import WordprocessingDocumentFactory | ||
|
||
|
||
class HeadingTestCase(DocumentGeneratorTestCase): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have a testcase named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I should rename the other class to drop the FieldCode, since the module is test_field_code? |
||
def test_styles_are_ignored(self): | ||
style_xml = ''' | ||
<style styleId="heading1" type="paragraph"> | ||
<name val="Heading 1"/> | ||
<rPr> | ||
<b val="on"/> | ||
<caps val="on"/> | ||
<smallCaps val="on"/> | ||
<strike val="on"/> | ||
<dstrike val="on"/> | ||
</rPr> | ||
</style> | ||
''' | ||
|
||
document_xml = ''' | ||
<p> | ||
<pPr> | ||
<pStyle val="heading1"/> | ||
</pPr> | ||
<r> | ||
<fldChar fldCharType="begin"/> | ||
</r> | ||
<r> | ||
<instrText> FOOBAR baz</instrText> | ||
</r> | ||
<r> | ||
<fldChar fldCharType="separate"/> | ||
</r> | ||
<r> | ||
<t>AAA</t> | ||
</r> | ||
<r> | ||
<fldChar fldCharType="end"/> | ||
</r> | ||
</p> | ||
''' | ||
document = WordprocessingDocumentFactory() | ||
document.add(StyleDefinitionsPart, style_xml) | ||
document.add(MainDocumentPart, document_xml) | ||
|
||
expected_html = ''' | ||
<h1>AAA</h1> | ||
''' | ||
self.assert_document_generates_html(document, expected_html) | ||
|
||
|
||
class FieldCodeTestCase(DocumentGeneratorTestCase): | ||
def test_unsupported_instr_content_is_not_ignored(self): | ||
document_xml = ''' | ||
|
@@ -92,7 +139,7 @@ def test_multiple_instr_with_same_paragraph_parent(self): | |
self.assert_document_generates_html(document, expected_html) | ||
|
||
|
||
class HyperlinkFieldCodeTestCase(DocumentGeneratorTestCase): | ||
class HyperlinkTestCase(DocumentGeneratorTestCase): | ||
def test_spanning_single_paragraph(self): | ||
document_xml = ''' | ||
<p> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this at all. Could it benefit from a code comment, perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem was field.parent was never being set, so it was None. Yet the new field was being inserted into the structure. As a consequence, it mean that the contained runs had no way to detect whether they were contained within a paragraph that was a heading, since the structure only went up as far as the field.