rehypejs / rehype-minify

plugins to minify HTML
https://unifiedjs.com
MIT License
90 stars 16 forks source link

Ignore footnotes in hast-util-to-string #28

Closed vhpoet closed 5 years ago

vhpoet commented 5 years ago

Ignore footnotes.

Hast

AWS does offer a few products<sup id="fnref-nvcaorgblo.5gig5b"><a href="#fn-nvcaorgblo.5gig5b" class="footnote-ref">nvcaorgblo.5gig5b</a></sup> that fit into these other models, too.

Turns into

Before

AWS does offer a few productsnvcaorgblo.5gig5b that fit into these other models, too.

After

AWS does offer a few products that fit into these other models, too.
wooorm commented 5 years ago

Hi @vhpoet! Thanks for contributing! 👏

I don’t think supporting custom rules like this here makes sense, as I can see how other users would want to include footnotes, and others again would want different rules as well.

This project mimics the innerText DOM algorithm, and I don’t think it should deviate from that. There’s also hast-util-to-text, which mostly mimics textContent, and thus is closer to what you want to achieve here, but still not what you want.

But maybe I can advise better if I know the root of why and what you want to achieve?