An open API service indexing awesome lists of open source software.

https://github.com/webfoo/html-to-shopify-rich-text

A PHP package that converts HTML content to Shopify's Rich Text format. This package provides a simple and reliable way to transform HTML content into the JSON structure that Shopify's Rich Text editor expects.
https://github.com/webfoo/html-to-shopify-rich-text

parser php shopify

Last synced: 4 months ago
JSON representation

A PHP package that converts HTML content to Shopify's Rich Text format. This package provides a simple and reliable way to transform HTML content into the JSON structure that Shopify's Rich Text editor expects.

Awesome Lists containing this project

README

          

# HtmlToShopifyRichText

A PHP package that converts HTML content to Shopify's Rich Text format. This package provides a simple and reliable way to transform HTML content into the JSON structure that Shopify's Rich Text editor expects.

## Features

- Converts common HTML elements to Shopify Rich Text format
- Supports headings (h1-h6)
- Handles paragraphs, lists (ordered and unordered)
- Processes inline elements (bold, italic, links)
- Sanitizes HTML input
- Validates HTML structure
- Handles whitespace normalization
- Provides detailed error handling

## Installation

You can install the package via Composer:

```bash
composer require webfoo/html-to-shopify-rich-text
```

## Usage

```php
use Webfoo\HtmlToShopifyRichText\HtmlToShopifyRichText;

$html = '

Hello World

This is a test paragraph.

';
$richText = HtmlToShopifyRichText::convert($html);

// $richText will contain the JSON representation of the Shopify Rich Text
```

### Supported HTML Elements

- Headings: `

` through `

`
- Paragraphs: `

`
- Lists: `