wrap empty paragraph tags after import from XSweet
A surprising amount of the time we're getting content coming in from XSweet that doesn't have tags around block-level elements. Take demo_1_.docx, one of our standard test imports: if you look carefully at it, you'll see that the label on this table:
which says "Source: Fictitious data, for illustration purposes only" comes into our current Kotahi imported concatenated onto the next paragraph:
(If you look after the table, you can see that the label has become part of the next paragraph.)
This is probably a bug in XSweet! It would be better if it were fixed there. But I've added a pretty simple function to upload.js
that goes through incoming content – if it doesn't have a tag, it wraps a <p>
tag around it. This might not always be right, but we're not smooshing paragraphs together. So we get this:
If this were fixed in XSweet, we could take this out of the chain. In the interim, I think this would probably help clean up what's coming into Kotahi. I suspect we're not noticing these errors a lot of the time.
(XSweet bug report: XSweet/XSweet#182 )