Skip to content

oxfmt: support HTML5-honest doctype and void-element output #24645

Description

@schalkneethling

Summary

Oxfmt currently rewrites HTML like:

<!DOCTYPE html>
<meta charset="utf-8">

into:

<!doctype html>
<meta charset="utf-8" />

The trailing slash does not make an HTML void element self-closing; HTML ignores it. This output also conflicts with HTML validators configured to require the conventional uppercase doctype and omit the misleading slash on void elements.

Request

Please consider either:

  • HTML-specific options for doctype case and void-element style; or
  • defaults that emit <!DOCTYPE html> and omit the slash from HTML void elements.

The current Oxfmt configuration reference documents HTML formatting options such as singleAttributePerLine and htmlWhitespaceSensitivity, but no controls for these two output choices.

Reproduction

With Oxfmt 0.58.0 (and after reviewing the 0.59.0 configuration reference):

printf "<!DOCTYPE html>\\n<meta charset=\\"utf-8\\">\\n" | oxfmt --stdin-filepath example.html

outputs:

<!doctype html>
<meta charset="utf-8" />

Downstream impact

Calavera is adding html-validate as an opt-in integration. We do not want to disable HTML formatting wholesale or weaken the validator defaults, so users selecting both tools currently need to review this known incompatibility. A formatter option would let both tools coexist without excluding HTML.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions