-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced the concept of standardized elements, which require less e…
…ffort to produce.
- Loading branch information
1 parent
8151443
commit a8e8360
Showing
11 changed files
with
193 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*, ::before, ::after { | ||
box-sizing: border-box; | ||
font-family: sans-serif; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace HtmlUtilities.Validated; | ||
|
||
/// <summary> | ||
/// Provides friendly syntax for use of standardized HTML elements. | ||
/// </summary> | ||
public abstract class StandardElement | ||
{ | ||
// Global attribute list from https://html.spec.whatwg.org/#global-attributes. | ||
|
||
/// <summary> | ||
/// Uniquely identifies an element. | ||
/// Source: https://dom.spec.whatwg.org/#concept-id | ||
/// </summary> | ||
public ValidatedAttributeValue? Id { get; set; } | ||
|
||
/// <summary> | ||
/// The title attribute represents advisory information for the element, such as would be appropriate for a tooltip. | ||
/// Source: https://html.spec.whatwg.org/#attr-title | ||
/// </summary> | ||
public ValidatedAttributeValue? Title { get; set; } | ||
|
||
private protected StandardElement() | ||
{ | ||
} | ||
|
||
internal abstract void Write(HtmlWriter writer); | ||
|
||
/// <summary> | ||
/// Writes global attributes to the provided <see cref="AttributeWriter"/>. | ||
/// </summary> | ||
/// <param name="writer">Receives the attributes.</param> | ||
private protected void Write(AttributeWriter writer) | ||
{ | ||
writer.Write(" id"u8, Id); | ||
writer.Write(" title"u8, Title); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace HtmlUtilities.Validated.Standardized; | ||
|
||
/// <summary> | ||
/// The HTML "link" element, from https://html.spec.whatwg.org/#the-link-element. | ||
/// </summary> | ||
public class Link : StandardElement | ||
{ | ||
/// <summary> | ||
/// Relationship between the document containing the hyperlink and the destination resource. | ||
/// </summary> | ||
public string? Rel { get; set; } | ||
|
||
/// <summary> | ||
/// Address of the hyperlink. | ||
/// </summary> | ||
public string? Href { get; set; } | ||
|
||
internal sealed override void Write(HtmlWriter writer) | ||
{ | ||
writer.WriteElementSelfClosing("<link>"u8, attributes => | ||
{ | ||
base.Write(attributes); | ||
|
||
attributes.Write(" rel"u8, Rel); | ||
attributes.Write(" href"u8, Href); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace HtmlUtilities.Validated.Standardized; | ||
|
||
/// <summary> | ||
/// Source: https://html.spec.whatwg.org/#the-style-element | ||
/// </summary> | ||
public class Style : StandardElement | ||
{ | ||
/// <summary> | ||
/// Text that gives a conformant style sheet. | ||
/// </summary> | ||
public ValidatedText Content { get; set; } | ||
|
||
/// <summary> | ||
/// Applicable media. | ||
/// </summary> | ||
public ValidatedAttributeValue? Media { get; set; } | ||
|
||
internal sealed override void Write(HtmlWriter writer) | ||
{ | ||
writer.WriteElement("<style>"u8, attributes => | ||
{ | ||
Write(attributes); | ||
attributes.Write(writer.cspNonce); | ||
|
||
attributes.Write(" media"u8, Media); | ||
}, children => children.WriteText(Content)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters