Skip to content

Treat <ol> like <ul> when parsing as HTML #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions extensions/example/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Beginning with 8.4, Tcl API is CONST'ified
*/
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION <= 3)
# define CONST84
# define const
#endif

extern char *Tdom_InitStubs (Tcl_Interp *interp, char *version, int exact);
Expand Down Expand Up @@ -139,7 +139,7 @@ TclExampleObjCmd(dummy, interp, objc, objv)
simpleCounter *counter;


static CONST84 char *exampleMethods[] = {
static const char *exampleMethods[] = {
"enable", "getresult", "remove",
NULL
};
Expand Down
6 changes: 3 additions & 3 deletions extensions/tnc/tnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Beginning with 8.4, Tcl API is CONST'ified
*/
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION <= 3)
# define CONST84
# define const
#endif

#ifndef TCL_THREADS
Expand Down Expand Up @@ -2363,7 +2363,7 @@ tnc_ValidateObjCmd (
Tcl_HashEntry *entryPtr;
TNC_Content *model;

static CONST84 char *validateMethods[] = {
static const char *validateMethods[] = {
"validateTree", "validateDocument", "validateAttributes",
"delete",
NULL
Expand Down Expand Up @@ -2824,7 +2824,7 @@ TclTncObjCmd(dummy, interp, objc, objv)
int methodIndex, result;
TNC_Data *tncdata;

static CONST84 char *tncMethods[] = {
static const char *tncMethods[] = {
"enable", "remove", "getValidateCmd",
NULL
};
Expand Down
4 changes: 2 additions & 2 deletions generic/dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ externalEntityRefHandler (
Tcl_Channel chan = (Tcl_Channel) NULL;
enum XML_Status status;
XML_Index storedNextFeedbackPosition;
CONST84 char *interpResult;
const char *interpResult;

if (info->document->extResolver == NULL) {
Tcl_AppendResult (info->interp, "Can't read external entity \"",
Expand Down Expand Up @@ -5298,7 +5298,7 @@ TclTdomObjCmd (dummy, interp, objc, objv)
Tcl_Obj *newObjName = NULL;
TEncoding *encoding;

static CONST84 char *tdomMethods[] = {
static const char *tdomMethods[] = {
"enable", "getdoc",
"setResultEncoding", "setStoreLineColumn",
"setExternalEntityResolver", "keepEmpties",
Expand Down
1 change: 0 additions & 1 deletion generic/dom.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
* Beginning with 8.4, Tcl API is CONST'ified
*/
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION <= 3)
# define CONST84
#endif

/*
Expand Down
43 changes: 27 additions & 16 deletions generic/domhtml.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ static void TranslateEntityRefs (
value += c-'a' + 10;
} else {
/* error */
break;
}
i++;
}
Expand All @@ -608,28 +609,36 @@ static void TranslateEntityRefs (
value += c-'0';
} else {
/* error */
break;
}
i++;
}
}
if (z[i]!=';') {
/* error */
}
from = i+1;
if (z[i] == ';') {
from = i+1;
#if TclOnly8Bits
z[to++] = value;
#else
if (value < 0x80) {
z[to++] = value;
} else if (value <= 0x7FF) {
z[to++] = (char) ((value >> 6) | 0xC0);
z[to++] = (char) ((value | 0x80) & 0xBF);
} else if (value <= 0xFFFF) {
z[to++] = (char) ((value >> 12) | 0xE0);
z[to++] = (char) (((value >> 6) | 0x80) & 0xBF);
z[to++] = (char) ((value | 0x80) & 0xBF);
#else
if (value < 0x80) {
z[to++] = value;
} else if (value <= 0x7FF) {
z[to++] = (char) ((value >> 6) | 0xC0);
z[to++] = (char) ((value | 0x80) & 0xBF);
} else if (value <= 0xFFFF) {
z[to++] = (char) ((value >> 12) | 0xE0);
z[to++] = (char) (((value >> 6) | 0x80) & 0xBF);
z[to++] = (char) ((value | 0x80) & 0xBF);
} else {
/* error */
while (from < i-1) {
z[to++] = z[from++];
}
}
} else {
/* error */
while (from < i-1) {
z[to++] = z[from++];
}
}
#endif
} else {
Expand Down Expand Up @@ -870,7 +879,8 @@ HTML_SimpleParse (
case 'i': if (!strcmp(pn,"i")) autoclose = 1; break;
case 'l': if (!strcmp(pn,"li")) autoclose = 1; break;
case 'n': if (!strcmp(pn,"noscript")) autoclose = 1; break;
case 'o': if (!strcmp(pn,"option")) autoclose = 1; break;
case 'o': if (!strcmp(pn,"option") ||
!strcmp(pn,"ol")) autoclose = 1; break;
case 'p': if (!strcmp(pn,"p")) autoclose = 1; break;
case 's': if (!strcmp(pn,"span")) autoclose = 1; break;
case 't': if (!strcmp(pn,"tbody") ||
Expand Down Expand Up @@ -1436,7 +1446,8 @@ HTML_SimpleParse (
case 'h': if (!strcmp(pn,"head") ||
!strcmp(pn,"html")) autoclose = 1; break;
case 'l': if (!strcmp(pn,"li")) autoclose = 1; break;
case 'o': if (!strcmp(pn,"option")) autoclose = 1; break;
case 'o': if (!strcmp(pn,"option") ||
!strcmp(pn,"ol")) autoclose = 1; break;
case 'p': if (!strcmp(pn,"p")) autoclose = 1; break;
case 't': if (!strcmp(pn,"tbody") ||
!strcmp(pn,"td") ||
Expand Down
2 changes: 1 addition & 1 deletion generic/domxslt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5876,7 +5876,7 @@ getExternalDocument (
int resultcode = 0;
char *resultType, *extbase, *xmlstring, *channelId, s[20];
Tcl_Obj *extResolver = NULL;
CONST84 char *str;
const char *str;
domDocument *doc;
xsltSubDoc *sdoc;
XML_Parser parser;
Expand Down
58 changes: 43 additions & 15 deletions generic/nodecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ NodeObjCmd (arg, interp, objc, objv)
parent = (domNode *)StackTop();
if (parent == NULL) {
Tcl_AppendResult(interp, "called outside domNode context", NULL);
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
doc = parent->ownerDocument;

Expand Down Expand Up @@ -323,28 +324,39 @@ NodeObjCmd (arg, interp, objc, objv)
Tcl_GetStringFromObj (objv[1], &len))!=0) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-disableOutputEscaping? text");
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
} else {
disableOutputEscaping = 1;
index = 2;
}
} else {
Tcl_WrongNumArgs(interp, 1, objv, "text");
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
}
tval = Tcl_GetStringFromObj(objv[index], &len);
switch (abs(type)) {
case TEXT_NODE_CHK:
if (!tcldom_textCheck (interp, tval, "text")) return TCL_ERROR;
if (!tcldom_textCheck (interp, tval, "text")) {
ret = TCL_ERROR;
goto end;
}
createType = TEXT_NODE;
break;
case COMMENT_NODE_CHK:
if (!tcldom_commentCheck (interp, tval)) return TCL_ERROR;
if (!tcldom_commentCheck (interp, tval)) {
ret = TCL_ERROR;
goto end;
}
createType = COMMENT_NODE;
break;
case CDATA_SECTION_NODE_CHK:
if (!tcldom_CDATACheck (interp, tval)) return TCL_ERROR;
if (!tcldom_CDATACheck (interp, tval)) {
ret = TCL_ERROR;
goto end;
}
createType = CDATA_SECTION_NODE;
break;
default:
Expand All @@ -364,17 +376,24 @@ NodeObjCmd (arg, interp, objc, objv)
case PROCESSING_INSTRUCTION_NODE:
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "target data");
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
tval = Tcl_GetStringFromObj(objv[1], &len);
if (abs(type) == PROCESSING_INSTRUCTION_NODE_NAME_CHK
|| abs(type) == PROCESSING_INSTRUCTION_NODE_CHK) {
if (!tcldom_PINameCheck (interp, tval)) return TCL_ERROR;
if (!tcldom_PINameCheck (interp, tval)) {
ret = TCL_ERROR;
goto end;
}
}
aval = Tcl_GetStringFromObj(objv[2], &dlen);
if (abs(type) == PROCESSING_INSTRUCTION_NODE_VALUE_CHK
|| abs(type) == PROCESSING_INSTRUCTION_NODE_CHK) {
if (!tcldom_PIValueCheck (interp, aval)) return TCL_ERROR;
if (!tcldom_PIValueCheck (interp, aval)) {
ret = TCL_ERROR;
goto end;
}
}
newNode = (domNode *)
domNewProcessingInstructionNode(doc, tval, len, aval, dlen);
Expand All @@ -384,7 +403,8 @@ NodeObjCmd (arg, interp, objc, objv)
case PARSER_NODE: /* non-standard node-type : a hack! */
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "markup");
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
ret = tcldom_appendXML(interp, parent, objv[1]);
break;
Expand Down Expand Up @@ -424,7 +444,8 @@ NodeObjCmd (arg, interp, objc, objv)
if ((len % 2)) {
Tcl_AppendResult(interp, "list must have "
"an even number of elements", NULL);
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
cmdObj = objv[2];
} else {
Expand All @@ -440,14 +461,16 @@ NodeObjCmd (arg, interp, objc, objv)
if (abs(type) == ELEMENT_NODE_ANAME_CHK
|| abs(type) == ELEMENT_NODE_CHK) {
if (!tcldom_nameCheck (interp, tval, "attribute", 0)) {
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
}
aval = Tcl_GetString(opts[i+1]);
if (abs(type) == ELEMENT_NODE_AVALUE_CHK
|| abs(type) == ELEMENT_NODE_CHK) {
if (!tcldom_textCheck (interp, aval, "attribute")) {
return TCL_ERROR;
ret = TCL_ERROR;
goto end;
}
}
domSetAttribute(newNode, tval, aval);
Expand All @@ -458,13 +481,18 @@ NodeObjCmd (arg, interp, objc, objv)
break;
}

if (type < 0 && newNode != NULL) {
end:
if (ret != TCL_ERROR && type < 0 && newNode != NULL) {
char buf[64];
tcldom_createNodeObj(interp, newNode, buf);
Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, strlen(buf)));
}

if (ret == TCL_OK) doc->nodeFlags |= NEEDS_RENUMBERING;
if (ret == TCL_ERROR && newNode) {
/* prevent errors from leaving half-added nodes in the document */
domDeleteNode(newNode, NULL, NULL); newNode = NULL;
}
return ret;
}

Expand Down Expand Up @@ -526,7 +554,7 @@ nodecmd_createNodeCmd (interp, objc, objv, checkName, checkCharData)
ELM_NODE, TXT_NODE, CDS_NODE, CMT_NODE, PIC_NODE, PRS_NODE
};

static CONST84 char *subcmds[] = {
static const char *subcmds[] = {
"elementNode", "textNode", "cdataNode", "commentNode", "piNode",
"parserNode", NULL
};
Expand Down
Loading