shon / tiptapy

Library that generates HTML output from JSON export of tiptap editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tiptapy

Library that generates HTML output from JSON export of tiptap editor

tiptapy

Install

pip install tiptapy

Usage

import tiptapy

s = """

{
  "type": "doc",
  "content": [
    {
      "type": "blockquote",
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "Readability counts."
            }
          ]
        },
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "marks": [
                {
                  "type": "link",
                  "attrs": { "href": "https://en.wikipedia.org/wiki/Zen_of_Python" }
                }
              ],
              "text": "Zen of Python"
            },
            {
              "type": "text", "text": " By "
            },
            {
              "type": "text",
              "marks": [
                {
                  "type": "bold"
                }
              ],
              "text": "Tom Peters"
            }
          ]
        }
      ]
    }
  ]
}
"""

out = tiptapy.to_html(s)
print(out)

Output

<blockquote>
  <p>Readability counts.</p>
  <p>
      <a href="https://en.wikipedia.org/wiki/Zen_of_Python">Zen of Python</a> By 
      <strong>Tom Peters</strong>
  </p>
</blockquote>

About

Library that generates HTML output from JSON export of tiptap editor

License:MIT License


Languages

Language:Python 88.4%Language:HTML 11.6%