docx_parser_converter.docx_to_html.converters.paragraph_converter module

class docx_parser_converter.docx_to_html.converters.paragraph_converter.ParagraphConverter[source]

Bases: object

A converter class for converting DOCX paragraphs to HTML.

static convert_paragraph(paragraph: Paragraph, numbering_schema) str[source]

Converts a paragraph to its HTML representation.

Parameters:
  • paragraph (Paragraph) – The paragraph to convert.

  • numbering_schema – The schema containing numbering definitions.

Returns:

The HTML representation of the paragraph.

Return type:

str

Example

Given a paragraph with text and numbering, the output HTML string might look like:

<p style="text-align:left;">
    <span style="font-family:Times New Roman;">1.</span>
    <span style="padding-left:7.2pt;"></span>
    This is a sample paragraph.
</p>
static convert_paragraph_properties(properties) str[source]

Converts paragraph properties to an HTML style attribute.

Parameters:

properties – The paragraph style properties to convert.

Returns:

The HTML style attribute representing the paragraph properties.

Return type:

str

Example

The output style attribute might look like:

' style="margin-top:12pt;margin-bottom:12pt;text-align:left;"'