Supported blocks#
collective.html2blocks converts HTML into the Volto block types below.
Each block type comes from a frontend package.
The site that receives the blocks must have that package installed, or the editor can't display the blocks.
The Default column says whether a block type is produced when no setting mentions it:
onProduced by default. You can disable it.
offNot produced unless you enable it. Blocks from add-ons are usually
off.alwaysAlways produced. It can't be disabled.
slateconverts every element without a more specific block.
Block types#
Block type |
Package |
Default |
Converted from |
|---|---|---|---|
|
|
off |
|
|
|
on |
|
|
|
on |
|
|
|
on |
|
|
|
always |
— |
|
|
on |
|
|
|
on |
|
|
|
on |
|
codeBlock options#
Option |
Type |
Default |
|---|---|---|
|
|
|
|
|
|
|
|
|
Enable, disable and configure blocks#
Every entry point takes the same setting, keyed by the block type.
true, or a dictionary of options, enables a block type.
false disables it.
Block types left out keep their default state.
- Python
Pass
blockstohtml_to_blocks(),markdown_to_blocks()orvolto_blocks().from collective.html2blocks.converter import volto_blocks info = volto_blocks( source, blocks={"codeBlock": {"style": "light"}, "slateTable": False}, )
- Command line
Pass
--enable,--disableand--optiontoconvert.html2blocks convert --enable codeBlock --option codeBlock.style=light --disable slateTable page.md page.json
- HTTP service
Send a
blocksobject toPOST /html,POST /markdownorPOST /volto.{"html": "<pre>ls</pre>", "blocks": {"codeBlock": true}}
An unknown block type or option is an error, and so is a value of the wrong type. The command line exits with status 2, and the HTTP service answers with status 400.
Disabled blocks#
The elements of a disabled block type are converted as if it didn't exist:
A
<pre>withcodeBlockdisabled, and a<table>withslateTabledisabled, becomeslatetext.An
<iframe>whose provider block is disabled becomes aniframeblock. Withiframedisabled as well, it's dropped.An
<img>withimagedisabled, and a<video>withvideodisabled, are dropped.
List the blocks of an installation#
Add-ons can register more block types.
To list the block types of your installation, run the blocks command, or call GET /blocks on the HTTP service.
html2blocks blocks
html2blocks blocks --format json