comet.html¶
The html module provides utility functions for working with input and output HTML text.
Methods¶
- comet.html.getRawText(input)¶
Converts an HTML input string to raw text that no longer contains formatting tags.
All HTML entities and tags are removed. The input must be valid HTML.
- Parameters
input (str) – The input HTML text
- Returns
The raw text content
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- comet.html.toTagged(input, options)¶
Converts an HTML input string to InDesign® TaggedText.
Input must be valid XHTML.
See here for a description of supported HTML attributes.
- Parameters
- Returns
The convertext text content
- Return type
- Raises
TypeError – When parameter types are invalid
When parameter input is empty
When parameter options contains invalid values
CometError – On internal error
- Available
- CScript
- comet.html.exportText(input, options)¶
Export the content of a text frame as HTML.
Style information is put into a separate .css file into a subfolder in the target folder.
More information can be found here
- Parameters
input –
The source text to export.
The parameter type can be:
CFrame
:A text frame. This will export the entire text inside the frame’s chain.
CTextModel
:A text model. This exports the entire text inside the model.
tuple
[CTextModel
,int
,int
]A text model with start and length. Length may be -1 = to end
options (dict[str, int | bool | str]) –
Options for the export.
Keys must be
str
.The following options are available:
’kOutputFolder’
Value type:
str
Target folder.
Required when exporting to a file
When this option is provided, the function returns
None
.Also requires the additional option ‘kOutputName’.
’kOutputName’
Value type:
str
Name of the output file (without extension).
Required when exporting to a file
When this option is provided, the function returns
None
.Also requires the additional option ‘kOutputFolder’.
’kStartPosition’
Value type:
int
Default value: 0
Start index in the text model
When parameter input is
CTextModel
, this is relative to the text model!’kLength’
Value type:
int
Default value: -1
Length in the text model (-1 = until the end).
When parameter input is
CTextModel
, this is relative to the text model!’kCopyImages’
’kExportUnsupported’
Export in HTML unsupported images as .png?
’kInputCSS’
Value type:
str
Default value: ‘’
Alternative CSS.
When this parameter is set, the input is used as CSS instead of the generated one.
The input can be a path to a CSS file or a CSS definition.
’kCSSEscapeMode’
Value type:
int
Default value: 0
Which escape style should be used for unsupported characters in style names?
0: Hex Mode
1: Slash Mode
See here.
’kBodyOnly’
Export complete HMLT incl. <html><body> tags or only the <body> contents?
’kEscapeBrackets’
Create XML conform output?
- Returns
When exporting to a string: the result HTML string.
When exporting to a file:
None
- Return type
- Raises
TypeError – When parameter types are invalid
When parameter options contains invalid values
CometError – On internal error
- Available
- CScript