Code Monkey home page Code Monkey logo

Comments (7)

ChristianMurphy avatar ChristianMurphy commented on May 29, 2024 1

@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.

nwehner avatar nwehner commented on May 29, 2024 1

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.

ChristianMurphy avatar ChristianMurphy commented on May 29, 2024

@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.

nwehner avatar nwehner commented on May 29, 2024

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.

nwehner avatar nwehner commented on May 29, 2024

Note that the permitted content for HTML is:

One <head> element, followed by one <body> element.

from hast-util-to-html.

ChristianMurphy avatar ChristianMurphy commented on May 29, 2024

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.

nwehner avatar nwehner commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.