Loading generateBaseline/postprocessing.py +12 Changes for generateBaseline/postprocessing.py: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -803,6 +803,10 @@ def update_figure_style(docx_input, docx_output): root = etree.fromstring(xml_data) new_style = "FL" counter = 0 # 9.2in in EMU. Figures this tall are at the pandocFilter page cap, so one # line above them pushes the caption to the next page. Start those on a new page. tall_figure_cy = int(9.2 * 914400) drawing_ns = {"wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"} # Loop over all elements to find "ImageCaption" and change to "TF" for elem in root.xpath('.//w:pStyle[@w:val="CaptionedFigure"]', namespaces=ns): Loading @@ -811,6 +815,14 @@ def update_figure_style(docx_input, docx_output): pPr = elem.getparent() if pPr is not None and not pPr.xpath('./w:keepNext', namespaces=ns): pPr.append(OxmlElement('w:keepNext')) para = pPr.getparent() if pPr is not None else None if para is not None and pPr is not None: for extent in para.xpath('.//wp:extent', namespaces=drawing_ns): cy = extent.get('cy') if cy and cy.isdigit() and int(cy) >= tall_figure_cy: if not pPr.xpath('./w:pageBreakBefore', namespaces=ns): pPr.append(OxmlElement('w:pageBreakBefore')) break counter += 1 print(f'Changed style "CaptionedFigure" to "FL" {counter} times') Loading Loading
generateBaseline/postprocessing.py +12 Changes for generateBaseline/postprocessing.py: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -803,6 +803,10 @@ def update_figure_style(docx_input, docx_output): root = etree.fromstring(xml_data) new_style = "FL" counter = 0 # 9.2in in EMU. Figures this tall are at the pandocFilter page cap, so one # line above them pushes the caption to the next page. Start those on a new page. tall_figure_cy = int(9.2 * 914400) drawing_ns = {"wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"} # Loop over all elements to find "ImageCaption" and change to "TF" for elem in root.xpath('.//w:pStyle[@w:val="CaptionedFigure"]', namespaces=ns): Loading @@ -811,6 +815,14 @@ def update_figure_style(docx_input, docx_output): pPr = elem.getparent() if pPr is not None and not pPr.xpath('./w:keepNext', namespaces=ns): pPr.append(OxmlElement('w:keepNext')) para = pPr.getparent() if pPr is not None else None if para is not None and pPr is not None: for extent in para.xpath('.//wp:extent', namespaces=drawing_ns): cy = extent.get('cy') if cy and cy.isdigit() and int(cy) >= tall_figure_cy: if not pPr.xpath('./w:pageBreakBefore', namespaces=ns): pPr.append(OxmlElement('w:pageBreakBefore')) break counter += 1 print(f'Changed style "CaptionedFigure" to "FL" {counter} times') Loading