quill-delta-python icon indicating copy to clipboard operation
quill-delta-python copied to clipboard

code-blocks not being formatted

Open roguefalcon opened this issue 1 year ago • 0 comments

Thanks so much for your library. I recently used it in a project and it's pretty nice. Good job!

The only issue I'm seeing is that it doesn't wrap the code blocks in the <pre> tags or apply the ql-syntax class to them. I edited html.py to add the cls=BlockFormat to the following function:

@format("code-block", cls=BlockFormat)
def code_block(root, op):
    root.tag = "pre"
    root.attrib.update({"class": CODE_BLOCK_CLASS, "spellcheck": "false"})
    return root

That seemed to catch it and correctly start adding the appropriate tags. The only issue is that it adds them to every single line. You end up with blank space between each line of code which isn't ideal. I cheated to make it visually work by adding a negative margin via CSS to the ql-syntax class but I consider that a hack. It's working, and I'm totally going to ship it, but if there was a fix via this module that'd be my preferred option.

I poked around in the rest of your code trying to see if there was an easy fix and I didn't see an obvious way to group the code-block lines together. I probably just missed it.

Either way, great job on converting Delta to HTML! Super helpful and I really appreciate it.

roguefalcon avatar Apr 26 '24 19:04 roguefalcon