Skip to content

Commit e51cd17

Browse files
authored
Support the <slot> tag (#848)
* Support the <slot> tag <slot> was added to the WHATWG HTML5 Living Standard on April 20, 2016. * Also support the slot= attribute Given that the <slot> tag by itself is not too useful, this commit also introduces support for the global slot attribute. * Using ParseBlock for <slot> This is still suboptimal since ParseBlock will make it so that <slot> 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 <slot> 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.
1 parent 1889880 commit e51cd17

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

include/tidyenum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ typedef enum
988988
TidyTag_OUTPUT, /**< OUTPUT */
989989
TidyTag_PROGRESS, /**< PROGRESS */
990990
TidyTag_SECTION, /**< SECTION */
991+
TidyTag_SLOT, /**< SLOT */
991992
TidyTag_SOURCE, /**< SOURCE */
992993
TidyTag_SUMMARY, /**< SUMMARY */
993994
TidyTag_TEMPLATE, /**< TEMPLATE */
@@ -1143,6 +1144,7 @@ typedef enum
11431144
TidyAttr_SHOWGRIDX, /**< SHOWGRIDX= */
11441145
TidyAttr_SHOWGRIDY, /**< SHOWGRIDY= */
11451146
TidyAttr_SIZE, /**< SIZE= */
1147+
TidyAttr_SLOT, /**< SLOT= */
11461148
TidyAttr_SPAN, /**< SPAN= */
11471149
TidyAttr_SRC, /**< SRC= */
11481150
TidyAttr_SRCSET, /**< SRCSET= (HTML5) */

src/attrdict.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
{ TidyAttr_IS, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
9696
{ TidyAttr_LANG, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
9797
{ TidyAttr_ROLE, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
98+
{ TidyAttr_SLOT, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
9899
{ TidyAttr_SPELLCHECK, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
99100
{ TidyAttr_STYLE, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
100101
{ TidyAttr_TABINDEX, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 }, \
@@ -2880,6 +2881,17 @@ const AttrVersion TY_(W3CAttrsFor_SMALL)[] =
28802881
{ TidyAttr_UNKNOWN, 0 },
28812882
};
28822883

2884+
const AttrVersion TY_(W3CAttrsFor_SLOT)[] =
2885+
{
2886+
INCLUDE_ARIA
2887+
INCLUDE_MICRODATA
2888+
{ TidyAttr_NAME, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 },
2889+
INCLUDE_CORE_ATTRIBS
2890+
INCLUDE_CORE_EVENTS
2891+
INCLUDE_RDFA
2892+
{ TidyAttr_UNKNOWN, 0 },
2893+
};
2894+
28832895
const AttrVersion TY_(W3CAttrsFor_SOURCE)[] =
28842896
{
28852897
INCLUDE_ARIA

src/attrdict.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ extern const AttrVersion TY_(W3CAttrsFor_OUTPUT)[];
142142
extern const AttrVersion TY_(W3CAttrsFor_MENUITEM)[];
143143
extern const AttrVersion TY_(W3CAttrsFor_METER)[];
144144
extern const AttrVersion TY_(W3CAttrsFor_PROGRESS)[];
145+
extern const AttrVersion TY_(W3CAttrsFor_SLOT)[];
145146
extern const AttrVersion TY_(W3CAttrsFor_TEMPLATE)[];
146147
extern const AttrVersion TY_(W3CAttrsFor_TIME)[];
147148
extern const AttrVersion TY_(W3CAttrsFor_DATA)[];

src/attrs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ static const Attribute attribute_defs [] =
238238
{ TidyAttr_SHOWGRIDX, "showgridx", CH_BOOL }, /* TABLE Adobe golive*/
239239
{ TidyAttr_SHOWGRIDY, "showgridy", CH_BOOL }, /* TABLE Adobe golive*/
240240
{ TidyAttr_SIZE, "size", CH_NUMBER }, /* HR, FONT, BASEFONT, SELECT */
241+
{ TidyAttr_SLOT, "slot", CH_PCDATA },
241242
{ TidyAttr_SPAN, "span", CH_NUMBER }, /* COL, COLGROUP */
242243
{ TidyAttr_SRC, "src", CH_URL }, /* IMG, FRAME, IFRAME */
243244
{ TidyAttr_SRCSET, "srcset", CH_PCDATA }, /* IMG (HTML5) */

src/attrs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ Bool TY_(AttributeIsMismatched)(Node* node, AttVal* attval, TidyDocImpl* doc);
315315
#define attrIsSHOWGRIDX(av) AttrIsId( av, TidyAttr_SHOWGRIDX )
316316
#define attrIsSHOWGRIDY(av) AttrIsId( av, TidyAttr_SHOWGRIDY )
317317
#define attrIsSIZE(av) AttrIsId( av, TidyAttr_SIZE )
318+
#define attrIsSLOT(av) AttrIsId( av, TidyAttr_SLOT )
318319
#define attrIsSPAN(av) AttrIsId( av, TidyAttr_SPAN )
319320
#define attrIsSRC(av) AttrIsId( av, TidyAttr_SRC )
320321
#define attrIsSTANDBY(av) AttrIsId( av, TidyAttr_STANDBY )

src/tags.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static CheckAttribs CheckHTML;
151151
#define VERS_ELEM_OUTPUT (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
152152
#define VERS_ELEM_PROGRESS (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
153153
#define VERS_ELEM_SECTION (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
154+
#define VERS_ELEM_SLOT (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
154155
#define VERS_ELEM_SOURCE (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
155156
#define VERS_ELEM_SUMMARY (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
156157
#define VERS_ELEM_TEMPLATE (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
@@ -321,6 +322,7 @@ static Dict tag_defs[] =
321322
{ TidyTag_OUTPUT, "output", VERS_ELEM_OUTPUT, &TY_(W3CAttrsFor_OUTPUT)[0], (CM_INLINE), TY_(ParseInline), NULL },
322323
{ TidyTag_PROGRESS, "progress", VERS_ELEM_PROGRESS, &TY_(W3CAttrsFor_PROGRESS)[0], (CM_INLINE), TY_(ParseInline), NULL },
323324
{ TidyTag_SECTION, "section", VERS_ELEM_SECTION, &TY_(W3CAttrsFor_SECTION)[0], (CM_BLOCK), TY_(ParseBlock), NULL },
325+
{ TidyTag_SLOT, "slot", VERS_ELEM_SLOT, &TY_(W3CAttrsFor_SLOT)[0], (CM_BLOCK|CM_INLINE|CM_MIXED), TY_(ParseBlock), NULL },
324326
{ TidyTag_SOURCE, "source", VERS_ELEM_SOURCE, &TY_(W3CAttrsFor_SOURCE)[0], (CM_BLOCK|CM_INLINE|CM_EMPTY), TY_(ParseBlock), NULL },
325327
{ TidyTag_SUMMARY, "summary", VERS_ELEM_SUMMARY, &TY_(W3CAttrsFor_SUMMARY)[0], (CM_BLOCK), TY_(ParseBlock), NULL }, /* Is. #895 */
326328
{ TidyTag_TEMPLATE, "template", VERS_ELEM_TEMPLATE, &TY_(W3CAttrsFor_TEMPLATE)[0], (CM_BLOCK), TY_(ParseBlock), NULL },

0 commit comments

Comments
 (0)