tildeio / simple-html-tokenizer

A lightweight JavaScript library for tokenizing non-`<script>` HTML expected to be found in the `<body>` of a document
MIT License
84 stars 33 forks source link

Add codemod mode to support `<pre>\nhi</pre>` stability in codemods. #90

Closed rwjblue closed 3 years ago

rwjblue commented 3 years ago

There have been a few different takes on a fix here, but at the moment code like this:

<textarea>
  some content
</textarea>

Will always be parsed as if you had written <textarea>some content</textarea>. This is perfectly reasonable when the goal is to precompile templates for actual rendering (e.g. what Ember does) but it completely breaks the ability of codemod utilities to properly rewrite / update in a source <-> source scenario.

After this change, @glimmer/syntax will be able to pass through its own mode (which matches the type added here) and already opts folks in to this mental model. That mode is used by tools like Prettier and ember-template-recast already.


References:

dcyriller commented 3 years ago

This looks like a better take than #86. Thanks!