Comments (7)
@nwehner here is an example of <head>
and <body>
working, as expected.
var h = require('hastscript')
var toHtml = require("hast-util-to-html");
var tree = h('html', [
h('head', [h('title', 'example')]),
h('body', 'content')
])
toHtml(tree);
runnable version: https://runkit.com/embed/dfmvrvtvpe7g
Can you provide a runnable example of the issue you are seeing?
from hast-util-to-html.
Sure enough, as soon as I moved away from local to Cloud9 the issue wasn't around any more. Finally found the error was in an import statement, grabbing the wrong 'h' builder for the elements. That'll do it! Sorry, everyone.
from hast-util-to-html.
@nwehner can you clarify how the actual behavior is invalid?
Looking at the HTML spec
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
https://html.spec.whatwg.org/multipage/semantics.html#the-head-element
It looks like
<html>
<head>headContent</head>
<body>bodyContent</body>
</html>
would be invalid output.
Only <title>
, <link>
, <base>
, <script>
, <meta>
, and other metadata tags are allowable content in the <head>
tag.
Text and paragraphs are not.
from hast-util-to-html.
I think you are mistaken: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
The only valid syntax for HTML is
<html>
<head>metadata</head>
<body>content</body>
</html>
from hast-util-to-html.
Note that the permitted content for HTML is:
One
<head>
element, followed by one<body>
element.
from hast-util-to-html.
again the literal text metadata
used in the example, is not valid content for <head>
, it must be actual metadata tags, not text.
Note that the permitted content for HTML is:
One element, followed by one element.
The spec is a bit contradictory on this front, from the MDN docs on <head>
:
HTML5-compliant browsers automatically create a element if its tags are omitted in the markup.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#Notes
Meaning <head>
is an optional tag.
from hast-util-to-html.
A) "metadata" is a placeholder. I know that's not valid content, thank you.
B) Regardless if something is optional, if the option is present, it should be handled appropriately.
from hast-util-to-html.
Related Issues (20)
- Better SVG minification HOT 1
- allowDangerousCharacters is still encoding '&' when its set to true HOT 3
- Head elements are not wrapped in a Head tag HOT 3
- Support minifying comments further
- Do not use `Omit` type HOT 9
- Prevent kebab case datatype? HOT 7
- Circular dependencies breaks rollup and vite builds HOT 4
- Text is encoded even when setting allowDangerousCharacters/allowDangerousHtml HOT 6
- failed to compile ts code using hast-util-to-html HOT 5
- Add support to format the HTML in a tidy fashion HOT 9
- `list-style-type` is stringified incorrectly HOT 1
- Force self-closing tags to be manually closed tags HOT 8
- Add missing "type": "module" to package.json for Vite resolution HOT 3
- missing whitespace in root node HOT 2
- re: missing whitespace in root node HOT 5
- Request more control over escaping HOT 6
- Reduce dependencies size HOT 3
- How do I allow camel cased properties? HOT 4
- Do not output unneeded entities in `<script>` or `<style>` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hast-util-to-html.