docx_parser_converter.docx_to_html.html_generator module
- class docx_parser_converter.docx_to_html.html_generator.HtmlGenerator[source]
Bases:
objectA generator class for converting DOCX document schema to HTML.
- static generate_html(document_schema: DocumentSchema, numbering_schema: NumberingSchema) str[source]
Generates HTML content from the given document schema.
- Parameters:
document_schema (DocumentSchema) – The schema containing elements from document.xml.
numbering_schema – The schema containing numbering definitions.
- Returns:
The generated HTML content.
- Return type:
str
Example
The following is an example of how to generate HTML content:
html_content = HtmlGenerator.generate_html(document_schema, numbering_schema) print(html_content)
- static generate_html_body(doc_margins: DocMargins, elements: List[Paragraph | Table], numbering_schema: NumberingSchema) Element[source]
Generates the body of the HTML content from the given document elements.
- Parameters:
doc_margins – The document margins.
elements – The list of document elements (paragraphs and tables).
numbering_schema – The schema containing numbering definitions.
- Returns:
The generated HTML body element.
- Return type:
etree.Element
Example
The following is an example of how to generate the HTML body:
body_html = HtmlGenerator.generate_html_body(doc_margins, elements, numbering_schema) print(etree.tostring(body_html, pretty_print=True, encoding="unicode"))