Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:wip
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | HTML5CustomNames
Files: files | file ages | folders
SHA3-256: e77b8c28869fd4c6a3f6368a13917c4af2d29c1480bf4b481fd32353cc395718
User & Date: rolf 2024-06-30 23:23:35
Context
2024-07-01
13:15
Merged from trunk. check-in: ca48d4518e user: rolf tags: HTML5CustomNames
2024-06-30
23:23
wip check-in: e77b8c2886 user: rolf tags: HTML5CustomNames
2024-06-29
01:35
wip check-in: 2184b00aca user: rolf tags: HTML5CustomNames
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/dom.c.

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
            p += clen;
        else return 0;
    }
    return 1;
}

/*---------------------------------------------------------------------------
|   domIsHTMLCustomChar 
|
\--------------------------------------------------------------------------*/
int
domIsHTMLCustomName (
    const char *str
    )
{
    const char *p;
    int clen, dashseen = 0;
    Tcl_UniChar uniChar;








|



|







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
            p += clen;
        else return 0;
    }
    return 1;
}

/*---------------------------------------------------------------------------
|   domIsHTML5CustomName 
|
\--------------------------------------------------------------------------*/
int
domIsHTML5CustomName (
    const char *str
    )
{
    const char *p;
    int clen, dashseen = 0;
    Tcl_UniChar uniChar;

Changes to generic/dom.h.

912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
int            domIsChar (const char *str);
void           domClearString (char *str, char *replacement, domLength repllen,
                               Tcl_DString *clearedstr, int *changed);
int            domIsBMPChar (const char *str);
int            domIsComment (const char *str);
int            domIsCDATA (const char *str);
int            domIsPIValue (const char *str);
int            domIsHTMLCustomName (const char *str);
void           domCopyTo (domNode *node, domNode *parent, int copyNS);
void           domCopyNS (domNode *from, domNode *to);
domAttrNode *  domCreateXMLNamespaceNode (domNode *parent);
void           domRenumberTree (domNode *node);
int            domPrecedes (domNode *node, domNode *other);
void           domNormalize (domNode *node, int forXPath, 
                             domFreeCallback freeCB, void *clientData);







|







912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
int            domIsChar (const char *str);
void           domClearString (char *str, char *replacement, domLength repllen,
                               Tcl_DString *clearedstr, int *changed);
int            domIsBMPChar (const char *str);
int            domIsComment (const char *str);
int            domIsCDATA (const char *str);
int            domIsPIValue (const char *str);
int            domIsHTML5CustomName (const char *str);
void           domCopyTo (domNode *node, domNode *parent, int copyNS);
void           domCopyNS (domNode *from, domNode *to);
domAttrNode *  domCreateXMLNamespaceNode (domNode *parent);
void           domRenumberTree (domNode *node);
int            domPrecedes (domNode *node, domNode *other);
void           domNormalize (domNode *node, int forXPath, 
                             domFreeCallback freeCB, void *clientData);

Changes to generic/domhtml.c.

2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
                    *x = tolower(*x);
                    x++;
                }
                *x = c;
            } else {
                c = *x;
                *x = '\0'; /* temporarily terminate the string */
                rc = domIsHTMLCustomName (start+1);
                *x = c;
                if (!rc) {
                    goto readText;
                }
            }
            hasContent = 1;
            if (c==0) {







|







2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
                    *x = tolower(*x);
                    x++;
                }
                *x = c;
            } else {
                c = *x;
                *x = '\0'; /* temporarily terminate the string */
                rc = domIsHTML5CustomName (start+1);
                *x = c;
                if (!rc) {
                    goto readText;
                }
            }
            hasContent = 1;
            if (c==0) {

Changes to generic/tcldom.c.

224
225
226
227
228
229
230

231
232
233
234
235
236
237
    "    isComment string                                 \n"
    "    isCDATA string                                   \n"
    "    isPIValue string                                 \n"
    "    isName string                                    \n"
    "    isQName string                                   \n"
    "    isNCName string                                  \n"
    "    isPIName string                                  \n"

    "    featureinfo feature                              \n"
;

static char doc_usage[] =
    "Usage domDoc <method> <args>, where method can be:\n"
    "    documentElement ?objVar?                \n"
    "    getElementsByTagName name               \n"







>







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    "    isComment string                                 \n"
    "    isCDATA string                                   \n"
    "    isPIValue string                                 \n"
    "    isName string                                    \n"
    "    isQName string                                   \n"
    "    isNCName string                                  \n"
    "    isPIName string                                  \n"
    "    isHTML5CustomName string                         \n"
    "    featureinfo feature                              \n"
;

static char doc_usage[] =
    "Usage domDoc <method> <args>, where method can be:\n"
    "    documentElement ?objVar?                \n"
    "    getElementsByTagName name               \n"
7630
7631
7632
7633
7634
7635
7636

7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649

7650
7651
7652
7653
7654
7655
7656
        "createDocument",  "createDocumentNS",   "createNodeCmd",
        "parse",                                 "setStoreLineColumn",
        "isCharData",      "isName",             "isPIName",
        "isQName",         "isComment",          "isCDATA",
        "isPIValue",       "isNCName",           "createDocumentNode",
        "setNameCheck",    "setTextCheck",       "setObjectCommands",
        "featureinfo",     "isBMPCharData",      "clearString",

#ifdef TCL_THREADS
        "attachDocument",  "detachDocument",
#endif
        NULL
    };
    enum domMethod {
        m_createDocument,    m_createDocumentNS,   m_createNodeCmd,
        m_parse,                                   m_setStoreLineColumn,
        m_isCharData,        m_isName,             m_isPIName,
        m_isQName,           m_isComment,          m_isCDATA,
        m_isPIValue,         m_isNCName,           m_createDocumentNode,
        m_setNameCheck,      m_setTextCheck,       m_setObjectCommands,
        m_featureinfo,       m_isBMPCharData,      m_clearString

#ifdef TCL_THREADS
        ,m_attachDocument,   m_detachDocument
#endif
    };

    static const char *nodeModeValues[] = {
        "automatic", "command", "token", NULL







>












|
>







7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
        "createDocument",  "createDocumentNS",   "createNodeCmd",
        "parse",                                 "setStoreLineColumn",
        "isCharData",      "isName",             "isPIName",
        "isQName",         "isComment",          "isCDATA",
        "isPIValue",       "isNCName",           "createDocumentNode",
        "setNameCheck",    "setTextCheck",       "setObjectCommands",
        "featureinfo",     "isBMPCharData",      "clearString",
        "isHTML5CustomName",
#ifdef TCL_THREADS
        "attachDocument",  "detachDocument",
#endif
        NULL
    };
    enum domMethod {
        m_createDocument,    m_createDocumentNS,   m_createNodeCmd,
        m_parse,                                   m_setStoreLineColumn,
        m_isCharData,        m_isName,             m_isPIName,
        m_isQName,           m_isComment,          m_isCDATA,
        m_isPIValue,         m_isNCName,           m_createDocumentNode,
        m_setNameCheck,      m_setTextCheck,       m_setObjectCommands,
        m_featureinfo,       m_isBMPCharData,      m_clearString,
        m_isHTML5CustomName
#ifdef TCL_THREADS
        ,m_attachDocument,   m_detachDocument
#endif
    };

    static const char *nodeModeValues[] = {
        "automatic", "command", "token", NULL
7880
7881
7882
7883
7884
7885
7886





7887
7888
7889
7890
7891
7892
7893
            return tcldom_featureinfo(clientData, interp, --objc, objv+1);

        case m_isBMPCharData:
            CheckArgs(3,3,2,"string");
            SetBooleanResult(domIsBMPChar(Tcl_GetString(objv[2])));
            return TCL_OK;






        case m_clearString:
            CheckArgs(3,5,2,"?-replace ?replacement?? string");
            if (objc >= 4) {
                option = Tcl_GetString (objv[2]);
                if (option[0] == '-' && option[1] == 'r') {
                    if (Tcl_GetIndexFromObj (interp, objv[2],
                                             clearStringOptions, "option",







>
>
>
>
>







7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
            return tcldom_featureinfo(clientData, interp, --objc, objv+1);

        case m_isBMPCharData:
            CheckArgs(3,3,2,"string");
            SetBooleanResult(domIsBMPChar(Tcl_GetString(objv[2])));
            return TCL_OK;

        case m_isHTML5CustomName:
            CheckArgs(3,3,2,"string");
            SetBooleanResult(domIsHTMLCustomChar(Tcl_GetString(objv[2])));
            return TCL_OK;
        
        case m_clearString:
            CheckArgs(3,5,2,"?-replace ?replacement?? string");
            if (objc >= 4) {
                option = Tcl_GetString (objv[2]);
                if (option[0] == '-' && option[1] == 'r') {
                    if (Tcl_GetIndexFromObj (interp, objv[2],
                                             clearStringOptions, "option",

Changes to tests/htmlreader.test.

2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
</html>}

test html-2.9 {HTML parsing} {
    set doc [dom parse -html {<HTML><MATH-field>x = 1 + 1</MATH-field></HTML>}]
    set result [$doc asHTML]
    $doc delete
    set result
} {<html>&lt;MATH-field&gt;x = 1 + 1&lt;/MATH-field></html&gt;}

test html-2.10 {HTML parsing} {
    set doc [dom parse -html {<HTML><mytag>foo</mytag></HTML>}]
    set result [$doc asHTML]
    $doc delete
    set result
} {<html><mytag>foo</mytag></html>}

test html-2.11 {HTML parsing} {
    set doc [dom parse -html {<HTML><math-field>x = 1 + 1</math-field></HTML>}]
    set result [$doc asHTML]
    $doc delete
    set result
} {<HTML><math-field>x = 1 + 1</math-field></HTML>}


test html-3.1 {Bad data} {
    set data {line 6 column 17 - Warning: <script> lacks "type" attribute
line 10 column 17 - Warning: <script> lacks "type" attribute
        line 11 column 17 - Warning: <table> lacks "summary" attribute}
    set doc [dom parse -html $data]







|













|







2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
</html>}

test html-2.9 {HTML parsing} {
    set doc [dom parse -html {<HTML><MATH-field>x = 1 + 1</MATH-field></HTML>}]
    set result [$doc asHTML]
    $doc delete
    set result
} {<html>&lt;MATH-field&gt;x = 1 + 1&lt;/MATH-field&gt;</html&gt;}

test html-2.10 {HTML parsing} {
    set doc [dom parse -html {<HTML><mytag>foo</mytag></HTML>}]
    set result [$doc asHTML]
    $doc delete
    set result
} {<html><mytag>foo</mytag></html>}

test html-2.11 {HTML parsing} {
    set doc [dom parse -html {<HTML><math-field>x = 1 + 1</math-field></HTML>}]
    set result [$doc asHTML]
    $doc delete
    set result
} {<html><math-field>x = 1 + 1</math-field></html>}


test html-3.1 {Bad data} {
    set data {line 6 column 17 - Warning: <script> lacks "type" attribute
line 10 column 17 - Warning: <script> lacks "type" attribute
        line 11 column 17 - Warning: <table> lacks "summary" attribute}
    set doc [dom parse -html $data]