Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pydocx/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@

POINTS_PER_EM = 12

# Defined in 17.15.1.25
DEFAULT_AUTOMATIC_TAB_STOP_INTERVAL = 720 # twips

# Define the whitespace character
HTML_WHITE_SPACE = ' '

PYDOCX_STYLES = {
'insert': {
'color': 'green',
Expand Down
10 changes: 6 additions & 4 deletions pydocx/export/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, path):
self.footnote_tracker = []

self.captured_runs = None
self.paragraphs = []
self.complex_field_runs = []

self.node_type_to_export_func_map = {
Expand Down Expand Up @@ -299,6 +300,11 @@ def yield_body_children(self, body):
return self.yield_numbering_spans(body.children)

def export_paragraph(self, paragraph):
if self.first_pass:
# To properly handle contextual spacing we need to know what is the style
# of the previous and next paragraphs. So, we save all the paragraphs here.
self.paragraphs.append(paragraph)

children = self.yield_paragraph_children(paragraph)
results = self.yield_nested(children, self.export_node)
if paragraph.effective_properties:
Expand All @@ -310,10 +316,7 @@ def yield_paragraph_children(self, paragraph):
yield child

def get_paragraph_styles_to_apply(self, paragraph):
properties = paragraph.effective_properties
property_rules = [
(properties.justification, self.export_paragraph_property_justification),
(True, self.export_paragraph_property_indentation),
]
for actual_value, handler in property_rules:
if actual_value:
Expand All @@ -338,7 +341,6 @@ def export_run(self, run):
if self.first_pass:
if self.captured_runs is not None:
self.captured_runs.append(run)

# TODO squash multiple sequential text nodes into one?
results = self.yield_nested(run.children, self.export_node)
if run.effective_properties:
Expand Down
Loading