trename autoclose to isvoid (void element) - webdump - [FORK] git://git.codemadness.org/webdump
HTML git clone git://git.z3bra.org/webdump.git
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit a49448ef41b7d425b1b7c5a29119f52d1c735cd5
DIR parent 956ad097d43cce10c04be9cb5f3f97b4dc703067
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Mon, 9 Dec 2019 19:04:45 +0100
rename autoclose to isvoid (void element)
void elements are not allowed to be closed, so ignore them.
Diffstat:
M webdump.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
---
DIR diff --git a/webdump.c b/webdump.c
t@@ -74,7 +74,7 @@ struct tag {
const char *name;
enum DisplayType displaytype;
enum DisplayType parenttype; /* display type belonging to element */
- int autoclose;
+ int isvoid; /* "void" element */
};
struct node {
t@@ -610,9 +610,16 @@ xmltagstart(XMLParser *x, const char *t, size_t tl)
static void
xmltagend(XMLParser *p, const char *t, size_t tl, int isshort)
{
+ struct tag *found;
struct node *cur;
int i;
+ /* ignore closing of void elements, like </br>, which is not allowed */
+ if ((found = findtag(t))) {
+ if (!isshort && cur->tag.isvoid)
+ return;
+ }
+
cur = &nodes[curnode];
if (cur->tag.displaytype & DisplayBold)
t@@ -756,9 +763,9 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
newline();
}
- /* autoclose tags, such as <br> */
- if (!isshort && cur->tag.autoclose)
- xmltagend(p, t, tl, 0);
+ /* autoclose tags, such as <br>, pretend we are <br/> */
+ if (!isshort && cur->tag.isvoid)
+ xmltagend(p, t, tl, 1);
}
static void