[MOD] Get rid of childrenless tags in XMLd text

This commit is contained in:
LDA 2024-08-02 15:08:46 +02:00
commit 74f3fbdccc
3 changed files with 51 additions and 0 deletions

View file

@ -294,6 +294,7 @@ ShoveXML(XEP393Element *element, XMLElement *xmlparent)
{
XMLElement *head = xmlparent;
size_t i;
bool par = false;
if (!element || !xmlparent)
{
return;
@ -324,6 +325,7 @@ ShoveXML(XEP393Element *element, XMLElement *xmlparent)
case XEP393_LINE:
head = XMLCreateTag("p");
XMLAddChild(xmlparent, head);
par = true;
break;
case XEP393_QUOT:
head = XMLCreateTag("blockquote");
@ -360,6 +362,17 @@ ShoveXML(XEP393Element *element, XMLElement *xmlparent)
break;
default: break;
}
/* NOTE: Hack to get rid of stranded <p/>-tags with no
* children. */
if (par && ArraySize(head->children) == 0)
{
ArrayDelete(
xmlparent->children,
ArraySize(xmlparent->children) - 1
);
XMLFreeElement(head);
}
}
#include <StringStream.h>