docx_parser_converter.docx_to_txt.converters.numbering_converter module
- class docx_parser_converter.docx_to_txt.converters.numbering_converter.NumberingConverter[source]
Bases:
objectClass to convert numbering to plain text.
- static convert_numbering(paragraph: Paragraph, numbering_schema) str[source]
Convert numbering to plain text.
- Parameters:
paragraph (Paragraph) – The paragraph object.
numbering_schema – The numbering schema.
- Returns:
Plain text representation of the numbering.
- Return type:
str
Example
paragraph = Paragraph( properties=properties, runs=runs, numbering=numbering ) numbering_text = NumberingConverter.convert_numbering(paragraph, numbering_schema) print(numbering_text)
- static format_number(counter: int, numFmt: str) str[source]
Format the counter according to the specified numbering format.
- Parameters:
counter (int) – The counter value.
numFmt (str) – The numbering format.
- Returns:
The formatted number.
- Return type:
str
Example
formatted_number = NumberingConverter.format_number(1, 'decimal') print(formatted_number) # Output: '1'
- static get_numbering_level(numbering_schema, numId: int, ilvl: int) NumberingLevel[source]
Get the numbering level from the numbering schema.
- Parameters:
numbering_schema – The numbering schema.
numId (int) – The numbering ID.
ilvl (int) – The indent level.
- Returns:
The corresponding numbering level.
- Return type:
- Raises:
ValueError – If the numbering level is not found.
Example
numbering_level = NumberingConverter.get_numbering_level(numbering_schema, numId, ilvl)
- numbering_counters = {}
- static to_lower_letter(num: int) str[source]
Convert an integer to a lowercase letter (a-z).
- Parameters:
num (int) – The integer to convert.
- Returns:
The lowercase letter representation.
- Return type:
str
Example
letter = NumberingConverter.to_lower_letter(1) print(letter) # Output: 'a'