lower case doctype is not recognised
See original GitHub issue(Thanks so much for the library, it’s awesome. I’m particularly appreciative that it’s very flexible about the input, except in this case…)
Describe the bug
Lower case “doctype” is not supported, although it’s valid in HTML.
To Reproduce
Any input with doctype
as lowercase not upper case:
const fs = require('fs')
const { SaxEventType, SAXParser } = require('sax-wasm')
const saxWasmBuffer = fs.readFileSync(require.resolve('sax-wasm/lib/sax-wasm.wasm'))
const get_type = (t) => {
for (const [name, value] of Object.entries(SaxEventType)) {
if (t === value) {
return name
}
}
}
const str2array = (str) => new Uint8Array(Buffer.from(str, 'utf8'))
// Instantiate
const options = {highWaterMark: 32 * 1024}
const parser = new SAXParser(SaxEventType.Attribute | SaxEventType.CloseTag | SaxEventType.OpenTag | SaxEventType.Text | SaxEventType.Doctype, options)
parser.eventHandler = (event, data) => {
console.log(`${get_type(event)}:`, data.toJSON())
}
parser.prepareWasm(saxWasmBuffer).then(() => {
console.log('lower case:')
parser.write(str2array('<!doctype html>'))
parser.end()
console.log('upper case:')
parser.write(str2array('<!DOCTYPE html>'))
parser.end()
})
This prints nothing for the first case but does find the DOCTYPE
clause for the second case.
I think the problem might be:
which appears to require "DOCTYPE"
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Uppercase or lowercase doctype? - html - Stack Overflow
In both cases it is declared as the fixed string "DOCTYPE" (which is not a tag, it is a keyword). So in the...
Read more >Why is "DOCTYPE" uppercase but "html" lower?
The thing to keep in mind is that the document type declararation is not HTML or XML. It is SGML, the parent schema...
Read more >Bug: "doctype" in lowercase is not recognized - Mailing lists
I tried two (valid) HTML 4.01 files, whose only difference is that "DOCTYPE" is uppercase in one and lowercase in the other.
Read more >DOCTYPE does not need to be capitalized · Issue #17552
The ! and uppercase DOCTYPE is important, especially for older browsers. The html is not case sensitive. This statement isn't accurate.
Read more >A 3-Minute Guide to Doctype HTML - HubSpot Blog
The <!DOCTYPE> declaration is not case sensitive. Although most commonly written in all uppercase, you can write it as lowercase, sentence case, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Understood, I should be able to get to this shortly.
Thanks so much for resolving this, I’ve upgraded and tests are passing!