rwb27 / docubricksViewer

1 stars 0 forks source link

Support for rich text #3

Closed rwb27 closed 6 years ago

rwb27 commented 6 years ago

This issue is to track my progress implementing rich text support.

rwb27 commented 6 years ago

Question: do I want to just assume the string inside <description> tags is safe HTML? Not sure I do... Either way, we need to allow descriptions to hold more than just plain text. I think a sensible way to proceed is to work out a way to render an Element, taking care to let through only those tags that are safe.

rwb27 commented 6 years ago

I've now succeeded in getting basic HTML markup. The procedure is as follows:

This is all enabled by two tricks:

renderDescription will, if it's given an Element as argument, enumerate the children of that element. The result is an Array with exactly one element for each child node:

rwb27 commented 6 years ago

This code is in the rich_text_support branch of my fork at the moment. Shout if you want a pull request!

rwb27 commented 6 years ago

Incidentally, I don't believe this breaks anything - DocuBricks XML that includes HTML shouldn't kill the parser (though it is possible it will confuse the editor - haven't tested), and old-style DocuBricks XML will render fine in my modified viewer. At least my version of the viewer before the format change will handle XML with embedded HTML by stripping the tags and keeping the text content. It breaks links, but fails fairly gracefully.

rwb27 commented 6 years ago

Oh, and you can see it live on the OpenFlexure Microscope github site!

rwb27 commented 6 years ago

This is now added in the viewer upstream through pull request #11. No support in the editor yet, though.