docx_parser_converter.docx_to_html.converters.run_converter module

class docx_parser_converter.docx_to_html.converters.run_converter.RunConverter[source]

Bases: object

A converter class for converting DOCX runs to HTML.

static convert_run(run: Run, paragraph: Paragraph) str[source]

Converts a run to its HTML representation.

Parameters:
  • run (Run) – The run to convert.

  • paragraph (Paragraph) – The paragraph containing the run.

Returns:

The HTML representation of the run.

Return type:

str

Example

Given a run with bold text and a tab, the output HTML string might look like:

<span style="font-weight:bold;">This is bold text</span>
<span style="display:inline-block; width:36pt;"></span>
static convert_run_properties(properties: RunStyleProperties | None) str[source]

Converts run properties to an HTML style attribute.

Parameters:

properties (RunStyleProperties) – The run style properties to convert.

Returns:

The HTML style attribute representing the run properties.

Return type:

str

Example

The output style attribute might look like:

' style="font-weight:bold;font-style:italic;color:#FF0000;font-family:Arial;font-size:12pt;"'
static get_next_tab_width(paragraph: Paragraph) float[source]

Gets the width of the next tab stop for the paragraph.

Parameters:

paragraph (Paragraph) – The paragraph containing the tab stop.

Returns:

The width of the next tab stop in points.

Return type:

float

Example

The following gets the next tab width:

tab_width = RunConverter.get_next_tab_width(paragraph)
print(tab_width)  # Output: 36.0