Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/kotlinx/html/generate/humanizer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ fun humanizeJoin(parts: Iterable<String>, separator: String): String {
}

private fun String.replaceMistakesAndUglyWords() : String =
replace("dbl", "double")
replace("dbl", "double")
.replace("Dbl", "Double")
.replace("EnDO", "enDo")


private fun String.replaceHyphensToCamelCase() : String =
Expand Down
56 changes: 46 additions & 10 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/rules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,52 @@ val specialTypes = listOf(
fun specialTypeFor(tagName: String, attributeName: String): AttributeType? =
specialTypes["$tagName.$attributeName"] ?: specialTypes["*.$attributeName"]

val wellKnownWords = listOf("span", "class", "enabled?", "edit(able)?",
"^on", "encoded?", "form", "type",
"run", "href", "drag(gable)?",
"over", "mouse",
"start(ed)?", "legend", "end(ed)?", "stop", "key", "load(ed)?", "check(ed)?",
"time", "ready", "content", "changed?",
"click", "play(ing)?", "context",
"rows?", "cols?", "group(ed)?", "auto",
"list", "field", "data", "block", "scripts?",
"item", "area", "length", "colors?", "suspend", "focus", "touch", "loading"
val wellKnownWords = listOf(
"span",
"class",
"enabled?",
"edit(able)?",
"^on",
"encoded?",
"form",
"type",
"run",
"href",
"drag(gable)?",
"over",
"mouse",
"start(ed)?",
"legend",
"end(ed)?",
"stop",
"key",
"load(ed)?",
"check(ed)?",
"time",
"ready",
"content",
"changed?",
"click",
"play(ing)?",
"context",
"rows?",
"cols?",
"group(ed)?",
"auto",
"list",
"field",
"data",
"block",
"scripts?",
"item",
"area",
"length",
"colors?",
"suspend",
"focus",
"touch",
"loading",
"referrer",
).map { it.toRegex(RegexOption.IGNORE_CASE) }

val excludeAttributes = listOf("^item$").map { Pattern.compile(it, Pattern.CASE_INSENSITIVE) }
Expand Down
15 changes: 15 additions & 0 deletions buildSrc/src/main/resources/html_5.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,21 @@
<xsd:attribute name="rel" type="linkType"/>
<xsd:attribute name="hreflang" type="i18LanguageCode"/>
<xsd:attribute name="type" type="contentType"/>
<xsd:attribute name="referrerpolicy">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="no-referrer"/>
<xsd:enumeration value="no-referrer-when-downgrade"/>
<xsd:enumeration value="origin"/>
<xsd:enumeration value="origin-when-cross-origin"/>
<xsd:enumeration value="same-origin"/>
<xsd:enumeration value="strict-origin-when-cross-origin"/>
<xsd:enumeration value="unsafe-url"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="media" type="xsd:string"/>
<xsd:attribute name="download" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/kotlin/generated/gen-attributes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal val attributeBooleanBooleanOnOff : Attribute<Boolean> = BooleanAttribut

internal val attributeBooleanTicker : Attribute<Boolean> = TickerAttribute()

internal val attributeAReferrerPolicyEnumAReferrerPolicyValues : Attribute<AReferrerPolicy> = EnumAttribute(aReferrerPolicyValues)

internal val attributeButtonFormEncTypeEnumButtonFormEncTypeValues : Attribute<ButtonFormEncType> = EnumAttribute(buttonFormEncTypeValues)

internal val attributeButtonFormMethodEnumButtonFormMethodValues : Attribute<ButtonFormMethod> = EnumAttribute(buttonFormMethodValues)
Expand Down
5 changes: 4 additions & 1 deletion src/commonMain/kotlin/generated/gen-consumer-tags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.html.ABBR
import kotlinx.html.ADDRESS
import kotlinx.html.AREA
import kotlinx.html.ARTICLE
import kotlinx.html.AReferrerPolicy
import kotlinx.html.ASIDE
import kotlinx.html.AUDIO
import kotlinx.html.AreaShape
Expand Down Expand Up @@ -155,11 +156,13 @@ import kotlinx.html.VIDEO
public inline fun <T, C : TagConsumer<T>> C.a(
href: String? = null,
target: String? = null,
referrerPolicy: AReferrerPolicy? = null,
classes: String? = null,
crossinline block: A.() -> Unit = {},
): T {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
return A(attributesMapOf("href", href,"target", target,"class", classes), this)
return A(attributesMapOf("href", href,"target", target,"referrerpolicy",
referrerPolicy?.enumEncode(),"class", classes), this)
.visitAndFinalize(this, block)
}

Expand Down
12 changes: 12 additions & 0 deletions src/commonMain/kotlin/generated/gen-enums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ object AType {
val values : List<String> = listOf("textAsp", "textAsa", "textCss", "textHtml", "textJavaScript", "textPlain", "textScriptLet", "textXComponent", "textXHtmlInsertion", "textXml")
}

@Suppress("unused", "EnumEntryName")
enum class AReferrerPolicy(override val realValue : String) : AttributeEnum {
noReferrer("no-referrer"),
noReferrerWhenDowngrade("no-referrer-when-downgrade"),
origin("origin"),
originWhenCrossOrigin("origin-when-cross-origin"),
sameOrigin("same-origin"),
strictOriginWhenCrossOrigin("strict-origin-when-cross-origin"),
unsafeUrl("unsafe-url")
}

internal val aReferrerPolicyValues : Map<String, AReferrerPolicy> = AReferrerPolicy.entries.associateBy { it.realValue }
@Suppress("unused", "EnumEntryName")
enum class AreaShape(override val realValue : String) : AttributeEnum {
rect("rect"),
Expand Down
46 changes: 44 additions & 2 deletions src/commonMain/kotlin/generated/gen-tag-unions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,51 @@ inline fun SectioningOrFlowContent.section(classes : String? = null, crossinline
*/
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.a(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
inline fun FlowOrInteractiveOrPhrasingContent.a(href : String? = null, target : String? = null, referrerPolicy : AReferrerPolicy? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"class", classes), consumer).visit(block)
A(attributesMapOf("href", href,"target", target,"referrerpolicy", referrerPolicy?.enumEncode(),"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.noReferrerA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.noReferrer.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.noReferrerWhenDowngradeA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.noReferrerWhenDowngrade.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.originA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.origin.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.originWhenCrossOriginA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.originWhenCrossOrigin.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.sameOriginA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.sameOrigin.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.strictOriginWhenCrossOriginA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.strictOriginWhenCrossOrigin.realValue,"class", classes), consumer).visit(block)
}
@HtmlTagMarker
@OptIn(ExperimentalContracts::class)
inline fun FlowOrInteractiveOrPhrasingContent.unsafeUrlA(href : String? = null, target : String? = null, classes : String? = null, crossinline block : A.() -> Unit = {}) : Unit {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
A(attributesMapOf("href", href,"target", target,"referrerpolicy", AReferrerPolicy.unsafeUrl.realValue,"class", classes), consumer).visit(block)
}

/**
Expand Down
12 changes: 12 additions & 0 deletions src/commonMain/kotlin/generated/gen-tags-a.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ open class A(initialAttributes : Map<String, String>, override val consumer : Ta
get() = attributeStringString.get(this, "type")
set(newValue) {attributeStringString.set(this, "type", newValue)}

var referrerPolicy : AReferrerPolicy
get() = attributeAReferrerPolicyEnumAReferrerPolicyValues.get(this, "referrerpolicy")
set(newValue) {attributeAReferrerPolicyEnumAReferrerPolicyValues.set(this, "referrerpolicy", newValue)}

var media : String
get() = attributeStringString.get(this, "media")
set(newValue) {attributeStringString.set(this, "media", newValue)}

var downLoad : String
get() = attributeStringString.get(this, "download")
set(newValue) {attributeStringString.set(this, "download", newValue)}


}
val A.asFlowContent : FlowContent
Expand Down
5 changes: 4 additions & 1 deletion src/jsMain/kotlin/generated/gen-consumer-tags-js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.html.ABBR
import kotlinx.html.ADDRESS
import kotlinx.html.AREA
import kotlinx.html.ARTICLE
import kotlinx.html.AReferrerPolicy
import kotlinx.html.ASIDE
import kotlinx.html.AUDIO
import kotlinx.html.AreaShape
Expand Down Expand Up @@ -207,11 +208,13 @@ import org.w3c.dom.HTMLVideoElement
public inline fun TagConsumer<HTMLElement>.a(
href: String? = null,
target: String? = null,
referrerPolicy: AReferrerPolicy? = null,
classes: String? = null,
crossinline block: A.() -> Unit = {},
): HTMLAnchorElement {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
return A(attributesMapOf("href", href,"target", target,"class", classes), this)
return A(attributesMapOf("href", href,"target", target,"referrerpolicy",
referrerPolicy?.enumEncode(),"class", classes), this)
.visitAndFinalize(this, block) as HTMLAnchorElement
}

Expand Down
5 changes: 4 additions & 1 deletion src/wasmJsMain/kotlin/generated/gen-consumer-tags-wasm-js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.html.ABBR
import kotlinx.html.ADDRESS
import kotlinx.html.AREA
import kotlinx.html.ARTICLE
import kotlinx.html.AReferrerPolicy
import kotlinx.html.ASIDE
import kotlinx.html.AUDIO
import kotlinx.html.AreaShape
Expand Down Expand Up @@ -207,11 +208,13 @@ import org.w3c.dom.HTMLVideoElement
public inline fun TagConsumer<Element>.a(
href: String? = null,
target: String? = null,
referrerPolicy: AReferrerPolicy? = null,
classes: String? = null,
crossinline block: A.() -> Unit = {},
): HTMLAnchorElement {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
return A(attributesMapOf("href", href,"target", target,"class", classes), this)
return A(attributesMapOf("href", href,"target", target,"referrerpolicy",
referrerPolicy?.enumEncode(),"class", classes), this)
.visitAndFinalize(this, block) as HTMLAnchorElement
}

Expand Down