From d77863ffd79deff465cd93e18fe9a77992bd1eb2 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Thu, 28 Nov 2019 16:18:11 +0000 Subject: [PATCH 1/3] Support the tag was added to the WHATWG HTML5 Living Standard on April 20, 2016. --- include/tidyenum.h | 1 + src/attrdict.c | 11 +++++++++++ src/attrdict.h | 1 + src/tags.c | 2 ++ 4 files changed, 15 insertions(+) diff --git a/include/tidyenum.h b/include/tidyenum.h index 3daee5b38..fe3e3452b 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -988,6 +988,7 @@ typedef enum TidyTag_OUTPUT, /**< OUTPUT */ TidyTag_PROGRESS, /**< PROGRESS */ TidyTag_SECTION, /**< SECTION */ + TidyTag_SLOT, /**< SLOT */ TidyTag_SOURCE, /**< SOURCE */ TidyTag_SUMMARY, /**< SUMMARY */ TidyTag_TEMPLATE, /**< TEMPLATE */ diff --git a/src/attrdict.c b/src/attrdict.c index 23322d1a0..3781799a5 100644 --- a/src/attrdict.c +++ b/src/attrdict.c @@ -2880,6 +2880,17 @@ const AttrVersion TY_(W3CAttrsFor_SMALL)[] = { TidyAttr_UNKNOWN, 0 }, }; +const AttrVersion TY_(W3CAttrsFor_SLOT)[] = +{ + INCLUDE_ARIA + INCLUDE_MICRODATA + { TidyAttr_NAME, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, + INCLUDE_CORE_ATTRIBS + INCLUDE_CORE_EVENTS + INCLUDE_RDFA + { TidyAttr_UNKNOWN, 0 }, +}; + const AttrVersion TY_(W3CAttrsFor_SOURCE)[] = { INCLUDE_ARIA diff --git a/src/attrdict.h b/src/attrdict.h index 775ce400c..45763001f 100644 --- a/src/attrdict.h +++ b/src/attrdict.h @@ -142,6 +142,7 @@ extern const AttrVersion TY_(W3CAttrsFor_OUTPUT)[]; extern const AttrVersion TY_(W3CAttrsFor_MENUITEM)[]; extern const AttrVersion TY_(W3CAttrsFor_METER)[]; extern const AttrVersion TY_(W3CAttrsFor_PROGRESS)[]; +extern const AttrVersion TY_(W3CAttrsFor_SLOT)[]; extern const AttrVersion TY_(W3CAttrsFor_TEMPLATE)[]; extern const AttrVersion TY_(W3CAttrsFor_TIME)[]; extern const AttrVersion TY_(W3CAttrsFor_DATA)[]; diff --git a/src/tags.c b/src/tags.c index af2b7d962..79add54a1 100644 --- a/src/tags.c +++ b/src/tags.c @@ -152,6 +152,7 @@ static CheckAttribs CheckHTML; #define VERS_ELEM_OUTPUT (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) #define VERS_ELEM_PROGRESS (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) #define VERS_ELEM_SECTION (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) +#define VERS_ELEM_SLOT (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) #define VERS_ELEM_SOURCE (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) #define VERS_ELEM_SUMMARY (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) #define VERS_ELEM_TEMPLATE (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50) @@ -322,6 +323,7 @@ static Dict tag_defs[] = { TidyTag_OUTPUT, "output", VERS_ELEM_OUTPUT, &TY_(W3CAttrsFor_OUTPUT)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_PROGRESS, "progress", VERS_ELEM_PROGRESS, &TY_(W3CAttrsFor_PROGRESS)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_SECTION, "section", VERS_ELEM_SECTION, &TY_(W3CAttrsFor_SECTION)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, + { TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, { TidyTag_SOURCE, "source", VERS_ELEM_SOURCE, &TY_(W3CAttrsFor_SOURCE)[0], (CM_BLOCK|CM_INLINE|CM_EMPTY), TY_(ParseBlock), NULL }, { TidyTag_SUMMARY, "summary", VERS_ELEM_SUMMARY, &TY_(W3CAttrsFor_SUMMARY)[0], (CM_BLOCK), TY_(ParseInline), NULL }, { TidyTag_TEMPLATE, "template", VERS_ELEM_TEMPLATE, &TY_(W3CAttrsFor_TEMPLATE)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, From af4e025c72225ebe3ee1af10a6f278dbeefc8c48 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Fri, 29 Nov 2019 21:07:39 +0000 Subject: [PATCH 2/3] Also support the slot= attribute Given that the tag by itself is not too useful, this commit also introduces support for the global slot attribute. --- include/tidyenum.h | 1 + src/attrdict.c | 1 + src/attrs.c | 1 + src/attrs.h | 1 + src/tags.c | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/tidyenum.h b/include/tidyenum.h index fe3e3452b..543a82ef8 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -1144,6 +1144,7 @@ typedef enum TidyAttr_SHOWGRIDX, /**< SHOWGRIDX= */ TidyAttr_SHOWGRIDY, /**< SHOWGRIDY= */ TidyAttr_SIZE, /**< SIZE= */ + TidyAttr_SLOT, /**< SLOT= */ TidyAttr_SPAN, /**< SPAN= */ TidyAttr_SRC, /**< SRC= */ TidyAttr_SRCSET, /**< SRCSET= (HTML5) */ diff --git a/src/attrdict.c b/src/attrdict.c index 3781799a5..c92d64e09 100644 --- a/src/attrdict.c +++ b/src/attrdict.c @@ -95,6 +95,7 @@ { TidyAttr_IS, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ { TidyAttr_LANG, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ { TidyAttr_ROLE, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ + { TidyAttr_SLOT, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ { TidyAttr_SPELLCHECK, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ { TidyAttr_STYLE, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ { TidyAttr_TABINDEX, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \ diff --git a/src/attrs.c b/src/attrs.c index 4231935b8..ff4f0767e 100644 --- a/src/attrs.c +++ b/src/attrs.c @@ -238,6 +238,7 @@ static const Attribute attribute_defs [] = { TidyAttr_SHOWGRIDX, "showgridx", CH_BOOL }, /* TABLE Adobe golive*/ { TidyAttr_SHOWGRIDY, "showgridy", CH_BOOL }, /* TABLE Adobe golive*/ { TidyAttr_SIZE, "size", CH_NUMBER }, /* HR, FONT, BASEFONT, SELECT */ + { TidyAttr_SLOT, "slot", CH_PCDATA }, { TidyAttr_SPAN, "span", CH_NUMBER }, /* COL, COLGROUP */ { TidyAttr_SRC, "src", CH_URL }, /* IMG, FRAME, IFRAME */ { TidyAttr_SRCSET, "srcset", CH_PCDATA }, /* IMG (HTML5) */ diff --git a/src/attrs.h b/src/attrs.h index befdcd125..c950acbf4 100644 --- a/src/attrs.h +++ b/src/attrs.h @@ -315,6 +315,7 @@ Bool TY_(AttributeIsMismatched)(Node* node, AttVal* attval, TidyDocImpl* doc); #define attrIsSHOWGRIDX(av) AttrIsId( av, TidyAttr_SHOWGRIDX ) #define attrIsSHOWGRIDY(av) AttrIsId( av, TidyAttr_SHOWGRIDY ) #define attrIsSIZE(av) AttrIsId( av, TidyAttr_SIZE ) +#define attrIsSLOT(av) AttrIsId( av, TidyAttr_SLOT ) #define attrIsSPAN(av) AttrIsId( av, TidyAttr_SPAN ) #define attrIsSRC(av) AttrIsId( av, TidyAttr_SRC ) #define attrIsSTANDBY(av) AttrIsId( av, TidyAttr_STANDBY ) diff --git a/src/tags.c b/src/tags.c index 79add54a1..9f72a70a4 100644 --- a/src/tags.c +++ b/src/tags.c @@ -323,7 +323,7 @@ static Dict tag_defs[] = { TidyTag_OUTPUT, "output", VERS_ELEM_OUTPUT, &TY_(W3CAttrsFor_OUTPUT)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_PROGRESS, "progress", VERS_ELEM_PROGRESS, &TY_(W3CAttrsFor_PROGRESS)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_SECTION, "section", VERS_ELEM_SECTION, &TY_(W3CAttrsFor_SECTION)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, - { TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, + { TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_SOURCE, "source", VERS_ELEM_SOURCE, &TY_(W3CAttrsFor_SOURCE)[0], (CM_BLOCK|CM_INLINE|CM_EMPTY), TY_(ParseBlock), NULL }, { TidyTag_SUMMARY, "summary", VERS_ELEM_SUMMARY, &TY_(W3CAttrsFor_SUMMARY)[0], (CM_BLOCK), TY_(ParseInline), NULL }, { TidyTag_TEMPLATE, "template", VERS_ELEM_TEMPLATE, &TY_(W3CAttrsFor_TEMPLATE)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, From 99b6c664c12a30c2ca13cc3bb4975d4829a41093 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Mon, 2 Dec 2019 03:12:13 +0000 Subject: [PATCH 3/3] Using ParseBlock for This is still suboptimal since ParseBlock will make it so that always expects "Flow content", whereas the spec says that it should have a Transparent content model. In practice, it should allow all the cases that the spec allows for, but it will also allow some cases that the spec does not allow. Notably, if a tag is found in a Phrasing content (an inline context in libtidy lingo), it will wrongly let Flow content (block tags in libtidy lingo), whereas it shouldn't. But all in all, it's a good compromise. --- src/tags.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tags.c b/src/tags.c index 9f72a70a4..ba2ed8030 100644 --- a/src/tags.c +++ b/src/tags.c @@ -323,7 +323,7 @@ static Dict tag_defs[] = { TidyTag_OUTPUT, "output", VERS_ELEM_OUTPUT, &TY_(W3CAttrsFor_OUTPUT)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_PROGRESS, "progress", VERS_ELEM_PROGRESS, &TY_(W3CAttrsFor_PROGRESS)[0], (CM_INLINE), TY_(ParseInline), NULL }, { TidyTag_SECTION, "section", VERS_ELEM_SECTION, &TY_(W3CAttrsFor_SECTION)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, - { TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_INLINE), TY_(ParseInline), NULL }, + { TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_BLOCK|CM_INLINE|CM_MIXED), TY_(ParseBlock), NULL }, { TidyTag_SOURCE, "source", VERS_ELEM_SOURCE, &TY_(W3CAttrsFor_SOURCE)[0], (CM_BLOCK|CM_INLINE|CM_EMPTY), TY_(ParseBlock), NULL }, { TidyTag_SUMMARY, "summary", VERS_ELEM_SUMMARY, &TY_(W3CAttrsFor_SUMMARY)[0], (CM_BLOCK), TY_(ParseInline), NULL }, { TidyTag_TEMPLATE, "template", VERS_ELEM_TEMPLATE, &TY_(W3CAttrsFor_TEMPLATE)[0], (CM_BLOCK), TY_(ParseBlock), NULL },