docx_parser_converter.docx_to_html.converters.style_converter module

class docx_parser_converter.docx_to_html.converters.style_converter.StyleConverter[source]

Bases: object

A converter class for converting DOCX style properties to CSS style attributes.

static convert_bold(bold: bool) str[source]

Converts bold property to CSS style.

Parameters:

bold (bool) – The bold property.

Returns:

The CSS style string for bold.

Return type:

str

Example

The output style might look like:

font-weight:bold;
static convert_color(color: str) str[source]

Converts color property to CSS style.

Parameters:

color (str) – The color property.

Returns:

The CSS style string for color.

Return type:

str

Example

The output style might look like:

color:#FF0000;
static convert_doc_margins(margins: DocMargins) str[source]

Converts document margins to CSS style.

Parameters:

margins – The document margins.

Returns:

The CSS style string for document margins.

Return type:

str

Example

The output style might look like:

padding-top:36pt;padding-right:36pt;padding-bottom:36pt;padding-left:36pt;padding-top:18pt;padding-bottom:18pt;margin-left:18pt;
static convert_font(font: FontProperties) str[source]

Converts font properties to CSS style.

Parameters:

font (FontProperties) – The font properties.

Returns:

The CSS style string for font.

Return type:

str

Example

The output style might look like:

font-family:Arial;
static convert_indent(indent: IndentationProperties) str[source]

Converts indentation properties to CSS style.

Parameters:

indent (IndentationProperties) – The indentation properties.

Returns:

The CSS style string for indentation.

Return type:

str

Example

The output style might look like:

margin-left:36pt;margin-right:36pt;text-indent:36pt;
static convert_italic(italic: bool) str[source]

Converts italic property to CSS style.

Parameters:

italic (bool) – The italic property.

Returns:

The CSS style string for italic.

Return type:

str

Example

The output style might look like:

font-style:italic;
static convert_justification(justification: str) str[source]

Converts justification property to CSS style.

Parameters:

justification (str) – The justification property.

Returns:

The CSS style string for justification.

Return type:

str

Example

The output style might look like:

text-align:left;
static convert_size(size_pt: float) str[source]

Converts font size property to CSS style.

Parameters:

size_pt (float) – The font size in points.

Returns:

The CSS style string for font size.

Return type:

str

Example

The output style might look like:

font-size:12pt;
static convert_spacing(spacing: SpacingProperties) str[source]

Converts spacing properties to CSS style.

Parameters:

spacing (SpacingProperties) – The spacing properties.

Returns:

The CSS style string for spacing.

Return type:

str

Example

The output style might look like:

margin-top:12pt;margin-bottom:12pt;line-height:18pt;
static convert_underline(underline: str) str[source]

Converts underline property to CSS style.

Parameters:

underline (str) – The underline property.

Returns:

The CSS style string for underline.

Return type:

str

Example

The output style might look like:

text-decoration:underline;
text-decoration:line-through;
text-decoration:none;