Ghost Utils icon

Ghost Utils

A collection of utility nodes for Ghost

Actions2

Overview

This node provides utility functions for converting between HTML and Lexical formats, which are commonly used in rich text editing and content management systems. Specifically, the "Lexical to HTML" operation converts a Lexical JSON representation of content into an HTML string. This is useful when you want to render or export content stored in Lexical format as standard HTML for web pages, emails, or other HTML-based outputs.

Practical examples include:

  • Converting editor content saved in Lexical format into HTML for display on a website.
  • Transforming Lexical content into email-friendly HTML markup for newsletters or transactional emails.

Properties

Name Meaning
Lexical The Lexical JSON string representing the content to convert to HTML.
Target The target output format: either "HTML" for general HTML output or "Email" for email-specific HTML formatting.

Output

The node outputs a JSON object with the following fields:

  • html: A string containing the converted HTML content derived from the input Lexical JSON.
  • lexical: The original Lexical JSON string that was provided as input.

No binary data output is produced by this operation.

Dependencies

  • Uses the external package @tryghost/kg-lexical-html-renderer to perform the conversion from Lexical JSON to HTML.
  • No additional API keys or external services are required.
  • Requires the node to be configured with the appropriate input properties (lexical and target).

Troubleshooting

  • Invalid Lexical JSON: If the input Lexical string is malformed or invalid, the conversion will fail. Ensure the Lexical JSON is correctly formatted.
  • Unsupported Lexical Nodes: Some Lexical content might contain nodes or features not supported by the renderer, potentially resulting in incomplete or incorrect HTML output.
  • Target Option Effects: Choosing "Email" as the target may alter the HTML output to be more compatible with email clients. If the output looks unexpected, verify the target setting.
  • Error Handling: If an error occurs during conversion, the node can either stop execution or continue depending on the "Continue On Fail" setting. Errors include parsing issues or rendering exceptions.

Links and References

Discussion