-
Thank you for all of these ecosystem utilities! I'm new to them and can't figure out what I'm doing wrong here. Input html <form><label></label><fieldset><label></label><input><label></label><input></fieldset></form> Expected output <form>
<label></label>
<fieldset>
<label></label>
<input>
<label></label>
<input>
</fieldset>
</form> Trying this const vfile = await rehype()
.data('settings', { fragment: true })
.use(rehypeFormat, { indentInitial: false })
.process('<form><label></label><fieldset><label></label><input><label></label><input></fieldset></form>')
console.log(vfile.value) Actual output <form><label></label>
<fieldset><label></label><input><label></label><input></fieldset>
</form> |
Beta Was this translation helpful? Give feedback.
Answered by
wooorm
Dec 8, 2023
Replies: 2 comments 2 replies
-
Whitespace has meaning / is visible in certain cases in HTML. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
j4w8n
-
Ok, so it is possible to represent what we want in const oghtml =
`<form>
<label></label>
<fieldset>
<label></label>
<input>
<label></label>
<input>
</fieldset>
</form>`
/* Transform to hast. */
const hast = fromHtml(oghtml, { fragment: true })
console.log(JSON.stringify(hast, null, 2))
/* And back to the desired html structure. */
const html = toHtml(hast)
console.log(html) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whitespace has meaning / is visible in certain cases in HTML.
rehype-format
can’t add/remove whitespace in all places.