-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to not strip whitespace in th
, td
#45
Conversation
Can you show an example where this is broken? Here’s some related reading: |
Hi, thanks for your prompt response. I think I understood what exactly is happening. I've made a small reproduction here: At first check what happens with the current release:
Then apply changes in
|
Investigating this some more, most of why this is annoying is due to #32. What makes it hard to investigate, is that React often does not show warnings. So it’s hard to check. But I did check, with this tree. Every commented out text is whitespace that React (including 18.2) warns about: const tree = h("div", [
h("p", [" ", h("span", "a"), "\n", h("span", "b."), "\t"]),
h("table", {}, [
// " ",
h("thead", [
// " ",
h("tr", [
// " ",
h("th", [" ", h("span", "c"), "\n", h("span", "d."), "\t"]),
// "\n",
h("th", "e.")
// "\t"
]),
// "\n",
h("tr", [])
// "\t"
]),
// "\n",
h("tbody", [
// " ",
h("tr", [
// " ",
h("td", [" ", h("span", "f"), "\n", h("span", "g."), "\t"]),
// "\n",
h("td", "h.")
// "\t"
]),
// "\n",
h("tr", [])
// "\t"
]),
// "\t",
h("tfoot", [
// " ",
h("tr", [
// " ",
h("td", [" ", h("span", "i"), "\n", h("span", "j."), "\t"]),
// "\n",
h("td", "k.")
// "\t"
]),
// "\n",
h("tr", [])
// "\t"
])
])
]); |
th
, td
This comment has been minimized.
This comment has been minimized.
Thanks, released in 7.1.2! |
Thanks for your detailed explanation and the release too! |
Initial checklist
Description of changes
Since #29 rehype-react removes any whitespaces in table elements but
th
andtd
should not be its target when filtering because whitespaces are valid to appear inside them and of course React does not warn about them. This PR removesth
andtd
from the list of target table elements and adds tests to verify they remain the same. Thanks.