bustle/mobiledoc-kit

Parsing indented HTML throws errors and creates unnecessary whitespace

Closed this issue · 0 comments

When DOM is created from HTML that has been indented it contains many extra blank (but lengthy) textNodes. This was causing two problems:

  1. The SectionParser throws errors because textNodes can appear inside non-markerable sections (see error screenshot below)
  2. Sections can frequently end up with large amounts of whitespace at the beginning and end of the content. For rendering this is not much of a problem because browsers ignore insignificant whitespace, however the primary use-case of the DOM/Section parsers is to create mobiledoc for display in the editor - in this case all whitespace can be significant.

Error when parsing content such as:

<ul>
    <li>
        One
    </li>
</ul>

screenshot 2019-02-14 at 13 42 27