docx_parser_converter.docx_parsers.styles.run_properties_parser module

class docx_parser_converter.docx_parsers.styles.run_properties_parser.RunPropertiesParser[source]

Bases: object

A parser for extracting run properties from an XML element.

This class extracts and parses various properties related to run formatting, converting them into structured Pydantic models for further processing or conversion to other formats.

extract_all_caps(rPr_element: Element) bool | None[source]

Extracts all caps property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted all caps property.

Return type:

Optional[bool]

Example

The following is an example of an all caps setting in a run properties element:

<w:caps/>
extract_bold(rPr_element: Element) bool | None[source]

Extracts bold property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted bold property.

Return type:

Optional[bool]

Example

The following is an example of a bold setting in a run properties element:

<w:b/>
extract_character_spacing(rPr_element: Element) float | None[source]

Extracts character spacing property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted character spacing in points.

Return type:

Optional[float]

Example

The following is an example of a character spacing setting in a run properties element:

<w:spacing w:val="2"/>
extract_double_strikethrough(rPr_element: Element) bool | None[source]

Extracts double strikethrough property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted double strikethrough property.

Return type:

Optional[bool]

Example

The following is an example of a double strikethrough setting in a run properties element:

<w:dstrike/>
extract_emboss(rPr_element: Element) bool | None[source]

Extracts emboss property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted emboss property.

Return type:

Optional[bool]

Example

The following is an example of an emboss setting in a run properties element:

<w:emboss/>
extract_font_color(rPr_element: Element) str | None[source]

Extracts font color from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted font color.

Return type:

Optional[str]

Example

The following is an example of font color in a run properties element:

<w:color w:val="FF0000"/>
extract_font_size(rPr_element: Element) float | None[source]

Extracts font size from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted font size in points.

Return type:

Optional[float]

Example

The following is an example of font size in a run properties element:

<w:sz w:val="24"/>
extract_fonts(rPr_element: Element) FontProperties | None[source]

Extracts font properties from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted font properties.

Return type:

Optional[FontProperties]

Example

The following is an example of font properties in a run properties element:

<w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:eastAsia="SimSun" w:cs="Arial"/>
extract_hidden(rPr_element: Element) bool | None[source]

Extracts hidden property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted hidden property.

Return type:

Optional[bool]

Example

The following is an example of a hidden setting in a run properties element:

<w:vanish/>
extract_highlight(rPr_element: Element) str | None[source]

Extracts highlight property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted highlight property.

Return type:

Optional[str]

Example

The following is an example of a highlight setting in a run properties element:

<w:highlight w:val="yellow"/>
extract_italic(rPr_element: Element) bool | None[source]

Extracts italic property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted italic property.

Return type:

Optional[bool]

Example

The following is an example of an italic setting in a run properties element:

<w:i/>
extract_kerning(rPr_element: Element) int | None[source]

Extracts kerning property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted kerning property.

Return type:

Optional[int]

Example

The following is an example of a kerning setting in a run properties element:

<w:kern w:val="2"/>
extract_language_settings(rPr_element: Element) LanguageProperties | None[source]

Extracts language settings from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted language properties.

Return type:

Optional[LanguageProperties]

Example

The following is an example of language settings in a run properties element:

<w:lang w:val="en-US" w:eastAsia="zh-CN" w:bidi="ar-SA"/>
extract_outline(rPr_element: Element) bool | None[source]

Extracts outline property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted outline property.

Return type:

Optional[bool]

Example

The following is an example of an outline setting in a run properties element:

<w:outline/>
extract_shading(rPr_element: Element) str | None[source]

Extracts shading property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted shading property.

Return type:

Optional[str]

Example

The following is an example of a shading setting in a run properties element:

<w:shd w:val="clear" w:color="auto" w:fill="FFFF00"/>
extract_shadow(rPr_element: Element) bool | None[source]

Extracts shadow property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted shadow property.

Return type:

Optional[bool]

Example

The following is an example of a shadow setting in a run properties element:

<w:shadow/>
extract_small_caps(rPr_element: Element) bool | None[source]

Extracts small caps property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted small caps property.

Return type:

Optional[bool]

Example

The following is an example of a small caps setting in a run properties element:

<w:smallCaps/>
extract_strikethrough(rPr_element: Element) bool | None[source]

Extracts strikethrough property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted strikethrough property.

Return type:

Optional[bool]

Example

The following is an example of a strikethrough setting in a run properties element:

<w:strike/>
extract_text_position(rPr_element: Element) float | None[source]

Extracts text position property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted text position in points.

Return type:

Optional[float]

Example

The following is an example of a text position setting in a run properties element:

<w:position w:val="2"/>
extract_underline(rPr_element: Element) str | None[source]

Extracts underline property from the given run properties element.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted underline property.

Return type:

Optional[str]

Example

The following is an example of an underline setting in a run properties element:

<w:u w:val="single"/>
extract_underline_color(rPr_element: Element) str | None[source]

Extracts underline color from the underline element if present.

extract_vertical_align(rPr_element: Element) str | None[source]

Extracts vertical alignment (subscript/superscript) from the run properties.

Parameters:

rPr_element (ET.Element) – The run properties element.

Returns:

The extracted vertical alignment value.

Return type:

Optional[str]

parse(rPr_element: Element) RunStyleProperties[source]

Parses run properties from the given XML element.

Parameters:

rPr_element (ET.Element) – The run properties XML element.

Returns:

The parsed run style properties.

Return type:

RunStyleProperties

Example

The following is an example of run properties in a run properties element:

<w:rPr>
    <w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/>
    <w:sz w:val="24"/>
    <w:color w:val="FF0000"/>
    <w:b/>
    <w:i/>
    <w:u w:val="single"/>
    <w:strike/>
    <w:highlight w:val="yellow"/>
    <w:shd w:val="clear" w:color="auto" w:fill="FFFF00"/>
    <w:position w:val="2"/>
    <w:kern w:val="2"/>
    <w:spacing w:val="2"/>
    <w:emboss/>
    <w:outline/>
    <w:shadow/>
    <w:caps/>
    <w:smallCaps/>
</w:rPr>