batiste / pug-vdom

PUG template to HyperScript Virtual DOM
MIT License
18 stars 6 forks source link

Multi-line HTML buffers not supported #30

Open gryphonmyers opened 6 years ago

gryphonmyers commented 6 years ago

This example, demonstrated at https://pugjs.org/language/plain-text.html#literal-html is a problem:

<html>

body
  p Indenting the body tag here would make no difference.
  p HTML itself isn't whitespace-sensitive.

</html>

the individual lines of HTML cannot be parsed as valid HTML individually, which makes them tricky to parse into vdom nodes. Basically we would need to parse HTML text as we go, keeping track of opened tags and eventually appending nodes created within them once we encounter closing tags.

What sucks is we may need to also support

- var myOpeningTag = '<div>';
- var myClosingTag = '</div>';

| !{myOpeningTag}

body
  p Indenting the body tag here would make no difference.
  p HTML itself isn't whitespace-sensitive.

| !{myClosingTag}

which means the HTML parsing would have to happen at runtime. We should do some experiments with pug to be sure we are recreating the features correctly.