80 lines
2.1 KiB
Swift
80 lines
2.1 KiB
Swift
//
|
|
// Embed.swift
|
|
// HTMLStandard
|
|
//
|
|
// Generated on 09/23/2025.
|
|
// THIS FILE IS GENERATED. DO NOT EDIT.
|
|
//
|
|
import Foundation
|
|
|
|
/// <embed> Plugin
|
|
public class Embed : HTMLNode, IEmbedded, IFlow, IInteractive, IPalpable, IPhrasing {
|
|
|
|
/// Vertical dimension. Valid non-negative integer.
|
|
public var height:UInt? = nil
|
|
|
|
/// Address of the resource. Valid non-empty URL potentially surrounded by spaces.
|
|
public var src:URL? = nil
|
|
|
|
/// Type of embedded resource. Valid MIME type string.
|
|
public var type:String? = nil
|
|
|
|
/// Horizontal dimension. Valid non-negative integer.
|
|
public var width:UInt? = nil
|
|
|
|
|
|
public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws {
|
|
var globalAttr = GlobalAttributesBuilder()
|
|
for (key, attValue) in attributes {
|
|
switch (key) {
|
|
case "height":
|
|
height = UInt(attValue)
|
|
continue
|
|
case "src":
|
|
src = try URL(expect: attValue)
|
|
continue
|
|
case "type":
|
|
type = attValue
|
|
continue
|
|
case "width":
|
|
width = UInt(attValue)
|
|
continue
|
|
|
|
default: break
|
|
}
|
|
if globalAttr.trySetGlobalAttribute(key, attValue) {
|
|
continue
|
|
}
|
|
throw AppError("Unexpected attribute: \(key)")
|
|
}
|
|
super.init(globalAttr)
|
|
}
|
|
|
|
|
|
public override func renderAttributes() -> String {
|
|
var result = super.renderAttributes()
|
|
if let height = height {
|
|
result += " height='\(height)'"
|
|
}
|
|
if let src = src {
|
|
result += " src='\(src.absoluteString)'"
|
|
}
|
|
if let type = type {
|
|
result += " type='\(type)'"
|
|
}
|
|
if let width = width {
|
|
result += " width='\(width)'"
|
|
}
|
|
|
|
|
|
return result
|
|
}
|
|
|
|
override var nodeName: String {
|
|
return "embed"
|
|
}
|
|
|
|
override var isVoidElement: Bool {
|
|
return true
|
|
}
|
|
} |