html_lint

package module
v0.0.0-...-8c08eba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

html-lint

This is a very simple linter for HTML. It embodies moderately idiosyncratic views on good HTML style, but you can easily modify it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lint

func Lint(report *Report, node *html.Node, pathname string)

Lint applies all the Lint* functions and then recurses down the tree.

func LintAName

func LintAName(report *Report, node *html.Node, pathname string)

LintAName ensures that <a> does not have the name attribute (which is deprecated in favor of id).

func LintAltText

func LintAltText(report *Report, node *html.Node, pathname string)

LintAltText ensures that <img> has an alt attribute for accessibility.

func LintCurlyQuotes

func LintCurlyQuotes(report *Report, node *html.Node, pathname string)

LintCurlyQuotes ensures that non-code text nodes, alt attributes, and title attributes use curly quotes.

func LintFigureHasFigcaption

func LintFigureHasFigcaption(report *Report, node *html.Node, pathname string)

LintFigureHasFigcaption ensures that <figure> has a <figcaption> child.

func LintImgNestedInFigure

func LintImgNestedInFigure(report *Report, node *html.Node, pathname string)

LintImgNestedInFigure ensures that <img> is nested inside a <figure> parent.

func LintLazyLoading

func LintLazyLoading(report *Report, node *html.Node, pathname string)

LintLazyLoading ensures that <img> and <iframe> have loading=lazy and that <script> has type=module. These attributes improve loading and rendering performance; see https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading.

func LintNesting

func LintNesting(report *Report, reader io.Reader, pathname string)

LintNesting ensures that all tags are properly closed.

func LintTimeFormatting

func LintTimeFormatting(report *Report, node *html.Node, pathname string)

LintTimeFormatting ensures that <time> elements are correctly formatted.

func LintWidthAndHeight

func LintWidthAndHeight(report *Report, node *html.Node, pathname string)

LintWidthAndHeight ensures that <img> has width and height attributes. This improves rendering performance by avoiding janky reflows.

Types

type Report

type Report struct {
	io.Writer
	ErrorCount int
}

func (*Report) Println

func (r *Report) Println(objects ...interface{})

Directories

Path Synopsis
cmd
html-lint command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL