collective.html2blocks.commands#
Command Line Interface for html2blocks.
Package with implementation of each command available in the CLI.
collective.html2blocks.commands.convert#
Convert command for collective.html2blocks CLI.
This Typer subcommand provides functionality to convert HTML files to Volto blocks in JSON format. It checks file paths, reads HTML input, performs conversion, and writes the result to the specified output file.
Example
uv run html2blocks convert input.html output.json
- collective.html2blocks.commands.convert.check_path(path: Path) bool[source]#
Check if a file or directory path exists.
- Parameters:
path (Path) -- The path to check.
- Returns:
True if the path exists, False otherwise.
- Return type:
Example
>>> check_path(Path('input.html')) True
- collective.html2blocks.commands.convert.check_paths(src: Path, dst: Path) bool[source]#
Check if both source and destination paths exist, printing errors if not.
- Parameters:
src (Path) -- Source file path.
dst (Path) -- Destination directory path.
- Returns:
True if both exist, False otherwise.
- Return type:
- collective.html2blocks.commands.convert.convert(src: ~typing.Annotated[~pathlib.Path, <typer.models.ArgumentInfo object at 0x7f49e3f77b60>], dst: ~typing.Annotated[~pathlib.Path, <typer.models.ArgumentInfo object at 0x7f49e3f77bc0>])[source]#
Convert an HTML file to Volto blocks JSON.
This command reads the HTML file at
src, converts its contents to Volto blocks using the package's converter, and writes the result as JSON todst.- Parameters:
src (Path) -- Path to the HTML file to convert.
dst (Path) -- Path to write the JSON output.
Example
uv run html2blocks convert input.html output.json
Converted input.html contents into file output.json
collective.html2blocks.commands.info#
Info command for collective.html2blocks CLI.
This Typer subcommand displays information about the tool, including the package name, version, and registered block and element converters.
Example
uv run html2blocks info
- collective.html2blocks.commands.info.tool_information()[source]#
Show information about the
collective.html2blockstool and its registrations.This command prints the package name, version, and lists all registered block and element converters, helping users understand the available conversion logic.
Example
uv run html2blocks info
# collective.html2blocks - 1.0.0 ## Block Converters - p: module.convert_paragraph - div: module.convert_div ## Element Converters - span: module.convert_span
collective.html2blocks.commands.server#
Server command for collective.html2blocks CLI.
This Typer subcommand runs the HTML to Blocks API service using Uvicorn. It allows you to specify host, port, and reload options for development.
Example
uv run html2blocks server --host 0.0.0.0 --port 8080 --reload
- collective.html2blocks.commands.server.serve(host: str = '127.0.0.1', port: int = 8000, reload: bool = False)[source]#
Run the HTML to Blocks API service.
This command starts a Uvicorn server hosting the FastAPI app for converting HTML to Volto blocks. You can customize the host, port, and enable reload for development.
- Parameters:
Example
uv run html2blocks server --host 0.0.0.0 --port 8080 --reload
Starting HTML to Blocks service at http://0.0.0.0:8080