Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit 653bc78

Browse files
committed
even more tags
1 parent eb3c83c commit 653bc78

21 files changed

+406
-35
lines changed

Sources/SwiftHTML/Tags/H1Tag.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
/// **Note:** Only use one `<h1>` per page - this should represent the main heading/subject for the whole page.
66
/// Also, do not skip heading levels - start with `<h1>`, then use `<h2>`, and so on.
77
public struct H1:
8-
HTMLStandardTag
8+
HTMLStandardTag,
9+
/// attribute modifiers
10+
GlobalAttributeModifier
911
{
1012

13+
/// The attribute storage for the tag.
1114
public var attributes: AttributeStore
15+
16+
/// The child elements contained within the tag.
1217
public var children: [Element]
1318

1419
/// The content model category for the tag.
1520
public var categories: ContentModel {
1621
[
17-
.heading
22+
.flow,
23+
.heading,
24+
.palpable,
1825
]
1926
}
2027

Sources/SwiftHTML/Tags/H2Tag.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
/// **Note:** Only use one `<h1>` per page - this should represent the main heading/subject for the whole page.
66
/// Also, do not skip heading levels - start with `<h1>`, then use `<h2>`, and so on.
77
public struct H2:
8-
HTMLStandardTag
8+
HTMLStandardTag,
9+
/// attribute modifiers
10+
GlobalAttributeModifier
911
{
1012

13+
/// The attribute storage for the tag.
1114
public var attributes: AttributeStore
15+
16+
/// The child elements contained within the tag.
1217
public var children: [Element]
1318

1419
/// The content model category for the tag.
1520
public var categories: ContentModel {
1621
[
17-
.heading
22+
.flow,
23+
.heading,
24+
.palpable,
1825
]
1926
}
2027

Sources/SwiftHTML/Tags/H3Tag.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
/// **Note:** Only use one `<h1>` per page - this should represent the main heading/subject for the whole page.
66
/// Also, do not skip heading levels - start with `<h1>`, then use `<h2>`, and so on.
77
public struct H3:
8-
HTMLStandardTag
8+
HTMLStandardTag,
9+
/// attribute modifiers
10+
GlobalAttributeModifier
911
{
1012

13+
/// The attribute storage for the tag.
1114
public var attributes: AttributeStore
15+
16+
/// The child elements contained within the tag.
1217
public var children: [Element]
1318

1419
/// The content model category for the tag.
1520
public var categories: ContentModel {
1621
[
17-
.heading
22+
.flow,
23+
.heading,
24+
.palpable,
1825
]
1926
}
2027

Sources/SwiftHTML/Tags/H4Tag.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
/// **Note:** Only use one `<h1>` per page - this should represent the main heading/subject for the whole page.
66
/// Also, do not skip heading levels - start with `<h1>`, then use `<h2>`, and so on.
77
public struct H4:
8-
HTMLStandardTag
8+
HTMLStandardTag,
9+
/// attribute modifiers
10+
GlobalAttributeModifier
911
{
1012

13+
/// The attribute storage for the tag.
1114
public var attributes: AttributeStore
15+
16+
/// The child elements contained within the tag.
1217
public var children: [Element]
1318

1419
/// The content model category for the tag.
1520
public var categories: ContentModel {
1621
[
17-
.heading
22+
.flow,
23+
.heading,
24+
.palpable,
1825
]
1926
}
2027

Sources/SwiftHTML/Tags/H5Tag.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
/// **Note:** Only use one `<h1>` per page - this should represent the main heading/subject for the whole page.
66
/// Also, do not skip heading levels - start with `<h1>`, then use `<h2>`, and so on.
77
public struct H5:
8-
HTMLStandardTag
8+
HTMLStandardTag,
9+
/// attribute modifiers
10+
GlobalAttributeModifier
911
{
1012

13+
/// The attribute storage for the tag.
1114
public var attributes: AttributeStore
15+
16+
/// The child elements contained within the tag.
1217
public var children: [Element]
1318

1419
/// The content model category for the tag.
1520
public var categories: ContentModel {
1621
[
17-
.heading
22+
.flow,
23+
.heading,
24+
.palpable,
1825
]
1926
}
2027

Sources/SwiftHTML/Tags/H6Tag.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@
55
/// **Note:** Only use one `<h1>` per page - this should represent the main heading/subject for the whole page.
66
/// Also, do not skip heading levels - start with `<h1>`, then use `<h2>`, and so on.
77
public struct H6:
8-
HTMLStandardTag
8+
HTMLStandardTag,
9+
/// attribute modifiers
10+
GlobalAttributeModifier
911
{
1012

13+
/// The attribute storage for the tag.
1114
public var attributes: AttributeStore
15+
16+
/// The child elements contained within the tag.
1217
public var children: [Element]
1318

1419
/// The content model category for the tag.
1520
public var categories: ContentModel {
1621
[
17-
.heading
22+
.flow,
23+
.heading,
24+
.palpable,
1825
]
1926
}
2027

Sources/SwiftHTML/Tags/HeadTag.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@
1313
/// - `<meta>`
1414
/// - `<script>`
1515
/// - `<noscript>`
16-
public struct Head: StandardTag {
16+
public struct Head:
17+
HTMLStandardTag,
18+
/// attribute modifiers
19+
GlobalAttributeModifier
20+
{
1721

22+
/// The attribute storage for the tag.
1823
public var attributes: AttributeStore
24+
25+
/// The child elements contained within the tag.
1926
public var children: [Element]
2027

28+
/// The content model category for the tag.
29+
public var categories: ContentModel {
30+
[]
31+
}
32+
2133
public init(
2234
elements: [Element]
2335
) {
Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,52 @@
1-
////
2-
//// Header.swift
3-
//// SwiftHtml
4-
////
5-
//// Created by Tibor Bodecs on 2021. 07. 19..
6-
////
7-
//
8-
///// The` <header>` element represents a container for introductory content or a set of navigational links.
9-
/////
10-
///// A` <header>` element typically contains:
11-
/////
12-
///// - one or more heading elements (`<h1>` - `<h6>`)
13-
///// - logo or icon
14-
///// - authorship information
15-
///// **Note:** You can have several` <header>` elements in one HTML document. However,` <header>` cannot be placed within a` <footer>`,` <address>` or another` <header>` element.
16-
//open class Header: Tag {
17-
//
18-
//}
1+
/// The` <header>` element represents a container for introductory content or a set of navigational links.
2+
///
3+
/// A` <header>` element typically contains:
4+
///
5+
/// - one or more heading elements (`<h1>` - `<h6>`)
6+
/// - logo or icon
7+
/// - authorship information
8+
/// **Note:** You can have several` <header>` elements in one HTML document. However,` <header>` cannot be placed within a` <footer>`,` <address>` or another` <header>` element.
9+
public struct Header:
10+
HTMLStandardTag,
11+
/// attribute modifiers
12+
GlobalAttributeModifier
13+
{
14+
15+
/// The attribute storage for the tag.
16+
public var attributes: AttributeStore
17+
18+
/// The child elements contained within the tag.
19+
public var children: [Element]
20+
21+
/// The content model category for the tag.
22+
public var categories: ContentModel {
23+
[
24+
.flow,
25+
.palpable,
26+
]
27+
}
28+
29+
init(
30+
attributes: AttributeStore = .init(),
31+
children: [Element]
32+
) {
33+
self.attributes = attributes
34+
self.children = children
35+
}
36+
37+
public init(
38+
_ contents: String
39+
) {
40+
self.init(
41+
children: [
42+
Text(contents)
43+
]
44+
)
45+
}
46+
47+
public init(
48+
@Builder<Element> _ block: () -> [Element]
49+
) {
50+
self.init(children: block())
51+
}
52+
}

Sources/SwiftHTML/Tags/HgroupTag.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
public struct Hgroup: StandardTag { //, HeadingContent */ {
1+
/// The <hgroup> tag is used to surround a heading and one or more <p> elements.
2+
///
3+
/// The heading inside the <hgroup> element can be any of the <h1> to <h6> headings.
4+
///
5+
/// Note: The <hgroup> element does not render as anything special in a browser. However, you can use CSS to style the <hgroup> element and its content.
6+
public struct Hgroup:
7+
HTMLStandardTag,
8+
/// attribute modifiers
9+
GlobalAttributeModifier
10+
{
211

12+
/// The attribute storage for the tag.
313
public var attributes: AttributeStore
14+
15+
/// The child elements contained within the tag.
416
public var children: [Element]
517

18+
/// The content model category for the tag.
19+
public var categories: ContentModel {
20+
[
21+
.flow,
22+
.heading,
23+
.palpable,
24+
]
25+
}
26+
627
init(
728
attributes: AttributeStore = .init(),
829
children: [Element]

Sources/SwiftHTML/Tags/HrTag.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
/// The `<hr>` tag defines a thematic break in an HTML page (a shift of topic).
22
///
33
/// The `<hr>` element is most often displayed as a horizontal rule that is used to separate content (or define a change) in an HTML page.
4-
public struct Hr: ShortTag {
5-
4+
public struct Hr:
5+
HTMLShortTag,
6+
/// attribute modifiers
7+
GlobalAttributeModifier
8+
{
9+
/// The attribute storage for the tag.
610
public var attributes: AttributeStore
711

12+
/// The content model category for the tag.
13+
public var categories: ContentModel {
14+
[
15+
.flow
16+
// select element inner content elements.
17+
]
18+
}
19+
820
public init() {
921
self.attributes = .init()
1022
}

0 commit comments

Comments
 (0)