-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blocks-conversion-tool should be deprecated #27
Comments
@tiberiuichim This looks like a bug, and I'll need to check whether it is a regression because I know I have seen it working better than what you showed. Whitespace between block-level elements is supposed to be ignored. Can you confirm which version of the blocks-conversion-tool image you used? Sometimes I've accidentally run with an old version of the image if the container was created some time ago. As for the broader point about switching from blocks-conversion-tool to the Python implementation: What I care about is being able to use a mature, well-tested implementation. I don't know if it is better to have only one of those, or to have one each in Node and in Python. I would be open to trying the Python implementation the next time I work on a migration. |
I do think it's kind of funny that the Python guys are working on the Node implementation and the Node guy is working on the Python implementation :) |
I'm an accidental node guy. My history with Plone started in 2004. I like to document the little bits that I find interesting and I think would help anyone, see my blog archive. https://play.pixelblaster.ro/archive/ But now I make the Volto bug tracker my rant area and this ticket my blogging space. |
I've used |
Since I'm doing two migrations to Volto at the moment using the blocks-conversion-tool I give plone/plone.volto#101 a try and compare the results. Will report back. |
@pbauer unfortunately the plone.volto PR is not a complete block migrator. You'll have to create a block generator in python, based on the output of the slate2html. You'll need to generate tables and images by traversing the slate JSON and extracting those nodes. This:
|
or you can pre-parse the html, extract images and tables and use the html2slate on the other "child fragments" |
The conversion from html to slate looks good to me but the fact that tables and images are not converted to the right blocks is a deal-breaker for me at the moment. I'll keep using the blocks-conversion-tool right now since I lack time to implementing the missing converters. Here is my slighty modified from plone.volto.slate.html2slate import text_to_slate
def get_blocks_from_richtext(text, service_url=None, slate=True):
blocks = {}
uuids = []
slate_data = text_to_slate(text)
for item in slate_data:
uuid = str(uuid4())
uuids.append(uuid)
block = {"@type": "slate"}
block["value"] = [item]
block["plaintext"] = "" # TODO
blocks[uuid] = block
return blocks, uuids |
@pbauer thanks for giving it a try! |
Some context:
I never actually needed to do any block conversion until this week.
I've always wished that we would be doing this conversion directly in Plone/python. Long ago I've started some code for this, under the umbrela of https://github.com/eea/eea.volto.slate. I've since moved that code to a plone.volto PR, which needs only final touch ups. If only I could motivate myself to do it...
I'm currently migrating a plone 4 website to Volto. We're keeping Plone 4, we're adding Volto on top of it. So I've started migrating blocks. Testing the blocks conversion on a first page I have the following html to convert:
With the blocks conversion tool, I get (I'm pasting an image, it's inconvenient to upload the text, it's on my remote dev machine):
Here's the output of that PR with a homegrown blocks conversion running that Python code (the bs4 version available for python2 is not ok for this task, so I'm doing my own block convertor as a service):
It's an output that perfectly matches the input html.
There's a big difference in how the newlines are handled in the new code: the Volto code has also been refactored to follow the same algorithm, the blocks-conversion tool is based on old Volto code.
The text was updated successfully, but these errors were encountered: