Skip to content

feat(file): name html as a file type, without a renderer for it - #769

Merged
andiwand merged 1 commit into
mainfrom
html-file-type
Aug 29, 2026
Merged

feat(file): name html as a file type, without a renderer for it#769
andiwand merged 1 commit into
mainfrom
html-file-type

Conversation

@andiwand

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Closes #763.

There is no FileType for html today, so an .html decodes as xml when it
happens to be well formed and as text when it is not — and a host that trusts
the answer shows the page's source instead of the page. iOS routes around it by
matching UTType against .html and .xhtml; Android has no such route and
opens an .html as an xml source tree.

This adds the row, and nothing else.

extensions html, htm, xhtml
MIME types text/html, application/xhtml+xml
category text
capabilities none

capabilities_by_file_type(hypertext_markup_language) declares no open and no
translate_html, so a host reads it as "the core names this and will not draw
it" and hands the file to the web view it already has — the shape psd, jp2,
wmf and emf took in 6.11.0. A passthrough renderer that emitted the file as
its own output would be of no use to such a host, and it would put the library
in the business of rewriting a page's document-relative links and assets.

Detection is by name: detect_by_content is false, as it is for markdown, since
html has no dependable signature and a probe for one is a probe for prose. What
matters is that file_type_by_file_extension("html") answers something other
than unknown. Detection from bytes is unchanged — a well formed .html still
lists as [text_file, xml].

FileType::hypertext_markup_language is appended to the enum, so the bindings
that mirror it by ordinal (jni, apple, python) gain the constant in the same
place; wasm derives its enum from the table already.

Test

FileTypeTable.html_is_named_but_not_decoded pins the aliases, the category,
the empty capabilities, and that opening a page as this type throws. The
table-wide invariants (one row per type, unique aliases, capabilities that do
not exceed the engines) cover the new row automatically.

Full odr_test suite: 1253 passed, 6 skipped (the pre-existing svm / encrypted
doc / wpd skips). Reference output is unchanged.

`.html` had no `FileType`, so a well formed one decoded as xml and a host
that trusted the answer showed the page's source. Both apps had to keep
their own list to route around it — exactly the kind of list the format
table exists to remove.

The row names html, htm, xhtml, text/html and application/xhtml+xml, and
declares nothing: no `open`, no `translate_html`. A passthrough renderer
would be of no use to a host that has a web view already, and it would put
the library in the business of rewriting a page's own links and assets.
Detection is by name, as it is for markdown — html has no dependable
signature.

Closes #763

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCM9ja9LbjNPPZGJZSw2xL
@andiwand
andiwand merged commit 859edee into main Aug 29, 2026
17 checks passed
@andiwand
andiwand deleted the html-file-type branch August 29, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name html as a file type, even without a renderer for it

1 participant