Command line reference

Command line reference#

The html2blocks command is installed with collective.html2blocks, but it needs an extra to run. Install collective.html2blocks[cli] for the convert, slate2plate and info commands. Install collective.html2blocks[server] for the server command. The all extra installs both sets. Run html2blocks --help to list the commands. Run html2blocks COMMAND --help to see the options of a command.

convert#

Convert an HTML or Markdown file to a JSON file with Volto blocks.

Usage: html2blocks convert [OPTIONS] SRC DST

Argument or option

Description

Default

SRC

Path to the HTML or Markdown file to read.

Required

DST

Path of the JSON file to write. Its parent folder must exist.

Required

--format

Input format, html or markdown.

Detected from the suffix of SRC

--converter

Output: slate for Volto blocks, or plate for the single Plate value of Plone Aurora.

slate

--plate-format

Where the Plate value goes: main for blocks.main, or somersault for the __somersault__ block of Aurora sites that have not upgraded yet. Only for --converter plate.

main

--title

Start the page with a title node with this text. Only for --converter plate.

No title

--enable BLOCK_TYPE

Enable a block type, such as codeBlock. Repeat the option to enable more.

The default state of each block type

--disable BLOCK_TYPE

Disable a block type, such as slateTable. Repeat the option to disable more.

The default state of each block type

--option BLOCK_TYPE.KEY=VALUE

Set an option of a block type, such as codeBlock.style=light. The option also enables the block type. Repeat the option to set more.

The defaults of the block type

The format is detected from the suffix of SRC. Files with the .md or .markdown suffix are read as Markdown. All other files are read as HTML.

If SRC does not exist, or if the parent folder of DST does not exist, the command prints a message and exits with status 1.

The block types, their default state and their options are listed in Supported blocks, and by the blocks command. Boolean option values are true, false, yes, no, on, off, 1 or 0. An unknown block type or option, a value of the wrong type, or a block type both enabled and disabled makes the command print a message and exit with status 2.

The output is JSON, written with an indentation of two spaces. It has the blocks and blocks_layout keys. With --converter plate, the main block is its only block, or the __somersault__ block with --plate-format somersault, as described in Plate output. Passing --title or --plate-format without --converter plate makes the command print a message and exit with status 2. An unknown --plate-format value also exits with status 2.

slate2plate#

Add the Plate value of Plone Aurora to a JSON file with a content item.

Usage: html2blocks slate2plate [OPTIONS] SRC DST

Argument or option

Description

Default

SRC

Path to the JSON file with the blocks and blocks_layout keys.

Required

DST

Path of the JSON file to write. Its parent folder must exist.

Required

--title

Text of the title node.

The title key of the content item

--plate-format

Where the Plate value goes: main for blocks.main, or somersault for the __somersault__ block of Aurora sites that have not upgraded yet.

main

The existing blocks stay in the output. A content item that already has a main or a __somersault__ block is written unchanged, whatever --plate-format asks for. An unknown --plate-format value makes the command exit with status 2.

If SRC does not exist, or if the parent folder of DST does not exist, the command prints a message and exits with status 1. If SRC does not hold a JSON object, the command prints a message and exits with status 2.

blocks#

List the Volto block types the converters can produce. For each block type, the report gives the frontend package that provides it, its default state, what it's converted from, and its options with their defaults.

Usage: html2blocks blocks [OPTIONS]

Option

Description

Default

--format

Output format: text, json or markdown.

text

The default state is on, off, or always for a block type that can't be disabled.

info#

Print the package name and version, followed by the block types with their package and default state, the block converters and the element converters that are registered.

Usage: html2blocks info

This command takes no options.

server#

Run the HTTP service with Uvicorn.

Usage: html2blocks server [OPTIONS]

Option

Description

Default

--host

Address to bind.

127.0.0.1

--port

Port to listen on.

8000

--reload / --no-reload

Restart the server when the source code changes. Use this option only during development.

--no-reload

The endpoints of the service are described in the Web service reference.