plone / blocks-conversion-tool

A tool to convert HTML (as used in Plone Classic) to Blocks (as used on Volto)
7 stars 5 forks source link

bold and italic formating is lost #25

Closed pbauer closed 1 year ago

pbauer commented 1 year ago

In older Plone-Versions it was the default by TinyMCE to style bold or italic text like this:

<p>Normal Text <span style="font-weight: bold;">Bold Text</span> more normal text</p>

Converting this results in:

{'@type': 'slate',
 'plaintext': 'Normal Text Bold Text more normal text',
 'value': [{'children': [{'children': [{'text': 'Normal Text '}], 'type': 'span'},
                         {'children': [{'text': 'Bold Text'}], 'type': 'span'},
                         {'children': [{'text': ' more normal text'}], 'type': 'span'}],
            'type': 'p'}]}
  1. All three text-parts are turned into spans which leads to ugly line-breaks in Volto.
  2. The styling is gone

It would be better to create this:

{'@type': 'slate',
 'plaintext': 'Normal Text Bold Text more normal text',
 'value': [{'children': [{'text': 'Normal Text '},
                         {'children': [{'text': 'Bold Text'}], 'type': 'strong'},
                         {'text': ' more normal text'}],
            'type': 'p'}]}

The same goes for <span style="font-style: italic">Italic text</span> which should get 'type': 'em'.