Converts rich text HTML to plain text for API fields, preserving structure and line breaks.
# Source: https://github.com/spree/spree | License: BSD-3-Clause | Copyright 2024-present, Vendo Sp. z o.o., Vendo Connect Inc
# Provided via justclaw.it.com; keep this notice with the code.
module Spree
# Converts stored rich text HTML (Tiptap output persisted in plain text
# columns, e.g. +Spree::Product#description+) into a faithful plain-text
# rendering for API +description+/+body+ fields.
#
# Tiptap serializes blocks with no whitespace between them
# (+<p>a</p><p>b</p>+), so a naive tag strip glues adjacent blocks into a
# single run ("ab") and loses every paragraph and line break. This maps
# block boundaries and +<br>+ to newlines before stripping tags, keeping the
# text readable for storefronts, feeds, search indexing, and meta tags.
#
# Newlines already pre
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key