117 lines
3.7 KiB
Swift
117 lines
3.7 KiB
Swift
//
|
|
// A.swift
|
|
// HTMLStandard
|
|
//
|
|
// Generated on 09/23/2025.
|
|
// THIS FILE IS GENERATED. DO NOT EDIT.
|
|
//
|
|
import Foundation
|
|
|
|
/// <a> Hyperlink
|
|
public class A : HTMLNode, IFlow, IInteractive, IPalpable, IPhrasing {
|
|
|
|
/// Whether to download the resource instead of navigating to it, and its file name if so.
|
|
public var download:String? = nil
|
|
|
|
/// Address of the hyperlink. Valid URL potentially surrounded by spaces.
|
|
public var href:URL? = nil
|
|
|
|
/// Language of the linked resource. Valid BCP 47 language tag.
|
|
public var hreflang:String? = nil
|
|
|
|
/// URLs to ping. Set of space-separated tokens consisting of valid non-empty URLs.
|
|
public var ping:[URL] = []
|
|
|
|
/// Referrer policy for fetches initiated by the element. Referrer policy.
|
|
public var referrerpolicy:ReferrerPolicy? = nil
|
|
|
|
/// Relationship between the location in the document containing the hyperlink and the destination resource. Unordered set of unique space-separated tokens. The actual rules are more complicated than indicated.
|
|
public var rel:[String] = []
|
|
|
|
/// Browsing context for hyperlink navigation. Valid browsing context name or keyword.
|
|
public var target:String? = nil
|
|
|
|
/// Hint for the type of the referenced resource. Valid MIME type string.
|
|
public var type:String? = nil
|
|
|
|
|
|
public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws {
|
|
var globalAttr = GlobalAttributesBuilder()
|
|
for (key, attValue) in attributes {
|
|
switch (key) {
|
|
case "download":
|
|
download = attValue
|
|
continue
|
|
case "href":
|
|
href = try URL(expect: attValue)
|
|
continue
|
|
case "hreflang":
|
|
hreflang = attValue
|
|
continue
|
|
case "ping":
|
|
ping = try URL.parseList(attValue, " ")
|
|
continue
|
|
case "referrerpolicy":
|
|
referrerpolicy = try ReferrerPolicy(expect: attValue)
|
|
continue
|
|
case "rel":
|
|
rel = try String.parseList(attValue, " ")
|
|
continue
|
|
case "target":
|
|
target = attValue
|
|
continue
|
|
case "type":
|
|
type = attValue
|
|
continue
|
|
|
|
default: break
|
|
}
|
|
if globalAttr.trySetGlobalAttribute(key, attValue) {
|
|
continue
|
|
}
|
|
continue
|
|
}
|
|
var allItems:[HTMLNode] = []
|
|
while let obj = try parser?.readObject(endTag: "a", xmlToHtmlMapper) {
|
|
allItems.append(obj)
|
|
}
|
|
super.init(globalAttr, allItems)
|
|
}
|
|
|
|
|
|
public override func renderAttributes() -> String {
|
|
var result = super.renderAttributes()
|
|
if let download = download {
|
|
result += " download='\(download)'"
|
|
}
|
|
if let href = href {
|
|
result += " href='\(href.absoluteString)'"
|
|
}
|
|
if let hreflang = hreflang {
|
|
result += " hreflang='\(hreflang)'"
|
|
}
|
|
result += " ping='\(ping.toStringList(" "))'"
|
|
if let referrerpolicy = referrerpolicy {
|
|
result += " referrerpolicy='\(referrerpolicy.rawValue)'"
|
|
}
|
|
result += " rel='\(rel.toStringList(" "))'"
|
|
if let target = target {
|
|
result += " target='\(target)'"
|
|
}
|
|
if let type = type {
|
|
result += " type='\(type)'"
|
|
}
|
|
|
|
|
|
return result
|
|
}
|
|
|
|
override var nodeName: String {
|
|
return "a"
|
|
}
|
|
|
|
override var isVoidElement: Bool {
|
|
return false
|
|
}
|
|
}
|