io.github.frikit.twirlspec.html

Members list

Type members

Classlikes

trait HtmlChecks extends TwirlSpecDsl

Adds the HTML validity rules to every display(...).

Adds the HTML validity rules to every display(...).

Attributes

Source
HtmlChecks.scala
Supertypes
trait TwirlSpecDsl
class Object
trait Matchable
class Any
Show all
Known subtypes
class HtmlStandards(attributePrefixes: Set[String]) extends RuleSet

Basic HTML validity, checked without a browser or a 20-dependency validator.

Basic HTML validity, checked without a browser or a 20-dependency validator.

well-formed-html reports what the parser had to repair, which catches a lot but describes the symptom rather than the cause. These read the markup as written and name the element and line responsible.

Value parameters

attributePrefixes

prefixes a project uses for its own attributes, beyond data- and aria-

Attributes

Companion
object
Source
HtmlStandards.scala
Supertypes
trait RuleSet
class Object
trait Matchable
class Any
Known subtypes
object HtmlStandards
object HtmlStandards extends HtmlStandards

The rules with no project-specific attribute prefixes.

The rules with no project-specific attribute prefixes.

Attributes

Companion
class
Source
HtmlStandards.scala
Supertypes
trait RuleSet
class Object
trait Matchable
class Any
Self type

The parts of the HTML vocabulary a checker needs to know to tell a mistake from a shorthand.

The parts of the HTML vocabulary a checker needs to know to tell a mistake from a shorthand.

Attributes

Source
HtmlVocabulary.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object TagBalance

Whether every element that was opened was closed, read from the source.

Whether every element that was opened was closed, read from the source.

By the time a parser hands back a tree the question cannot be asked: an unclosed `

` has already been closed for you. Jsoup does notice, but it reports the symptom — "Unexpected EndTag []" — rather than the cause, which leaves you counting tags by hand. This reads the markup as written and names the element and the line it was opened on.

It reads the source as the tokenizer of the HTML Living Standard, as of November 2026, reads it. Comments, doctypes, processing instructions, CDATA in SVG and MathML, quoted attribute values and the elements whose content is text, such as a script, a style or a textarea, open nothing. It departs from the standard twice. A quoted value that never closes ends its tag at the tag's first >, so the element is still reported rather than the rest of the page vanishing into the value. And a noscript is read as markup, as a browser with scripting off reads it.

It nests elements by their tags, knowing what HTML lets you leave out: void elements, the optional end tags, a paragraph ended by the start of a block (though not left open at the end of a link, a media element, an edit, a map, a noscript, a custom element or an SVG or MathML parent), and a slash closing only an SVG or MathML element. These are HTML's rules, so an SVG or MathML element of the same name keeps its own. It puts each element in the namespace a parser would: SVG and MathML, and HTML again at their integration points.

It does not repeat a parser's error recovery, such as breaking out of SVG, closing by scope, the adoption agency or foster parenting: it also reads template fragments with no page around them, and its job is to name the mistake in the source, not the tree a browser repairs it into.

Attributes

Source
TagBalance.scala
Supertypes
class Object
trait Matchable
class Any
Self type
TagBalance.type
object TwirlSource

A Twirl template with the Scala taken out, so that what is left is the HTML it writes.

A Twirl template with the Scala taken out, so that what is left is the HTML it writes.

Scanning a template rather than a rendered page is cheap — no application, no injector, no render — but the source is two languages at once, and one of them uses the angle brackets the other reserves for tags. @if(page < total) is a comparison, not the start of an element, and a scanner that cannot tell the difference reports every paginated page in a large codebase.

Everything belonging to an @ expression is blanked to spaces, keeping newlines so line numbers still point at the template. The { … } block that follows a construct like @if or @formHelper is left alone, because that part is HTML.

Attributes

Source
TwirlSource.scala
Supertypes
class Object
trait Matchable
class Any
Self type