Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Convert Quill delta to HTML

My existing project is using quill.js, And a sample quill content(delta) will look something like this

{
  "ops": [
    {
      "attributes": {
        "underline": true,
        "bold": true
      },
      "insert": " dfsdfdsf "
    },
    {
      "insert": "\n"
    }
  ]
}

Are there any pure python ways to convert these content into HTML?. I need this as a part of report generation to PDF on the server side using WeasyPrint.

Note: Kindly do not attempt to answer if you haven't used Quill.js before, or at least know what it is.

like image 500
nehem Avatar asked Jul 06 '26 05:07

nehem


1 Answers

If want to plain HTML in order to submit it to your server (for the entire edited document), you can just grab quill.root.innerHTML (which is the HTML inside the quill edit box) when your form is submitted (when the Submit button is pressed).

<form action="/SomeAction"
      method="POST"
      onsubmit="this['contents'].value = quill.root.innerHTML;"
      name="contentForm">
    <input type="hidden" name="id" value="239" />
    <input type="hidden" name="contents" value="" />
    <input type="submit" value="Submit">
</form>
like image 161
GlenPeterson Avatar answered Jul 07 '26 18:07

GlenPeterson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!