Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing whitespace in root node #33

Closed
4 tasks done
milahu opened this issue Nov 13, 2022 · 2 comments
Closed
4 tasks done

missing whitespace in root node #33

milahu opened this issue Nov 13, 2022 · 2 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@milahu
Copy link

milahu commented Nov 13, 2022

Initial checklist

Affected packages and versions

hast-util-from-parse5 7.1.0
hast-util-to-html 8.0.3
parse5 7.1.1

Link to runnable example

https://codepen.io/milahu/pen/eYKRmBW?editors=1010

Steps to reproduce

import {parse} from 'parse5'
import {fromParse5} from 'hast-util-from-parse5'
import {toHtml} from 'hast-util-to-html'

const source = `
<html>
  <head>
    <title>asdf</title>
  </head>
  <body>
    <div>asdf</div>
  </body>
</html>
`

function normalize(source) {
  const p5ast = parse(source, {
    sourceCodeLocationInfo: true,
  })
  const hast = fromParse5(p5ast)
  return toHtml(hast)
}

async function main() {

  console.log("input:")
  console.log(source)

  console.log("output:")
  console.log(normalize(source))
}

main()

Expected behavior

<html>
  <head>
    <title>asdf</title>
  </head>
  <body>
    <div>asdf</div>
  </body>
</html>

Actual behavior

<html><head>
    <title>asdf</title>
  </head>
  <body>
    <div>asdf</div>
  

</body></html>

Affected runtime and version

not relevant

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Nov 13, 2022
@wooorm
Copy link
Member

wooorm commented Nov 19, 2022

This is required by the HTML standard, which we follow.
That behavior is not always useful. If you want pretty HTML, use rehype-format!

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2022
@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label Nov 19, 2022
@github-actions

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants