v2.1.0 fixed smart quotes around links and inline code by concatenating all text into one string (allText) and converting that with retext-smartypants.
That introduced a small regression. Quotes at the start of a paragraph may be merged with another paragraph, which retext-smartypants will no longer recognize as opening quotes. For instance:
Hi there
"Some quote"
is incorrectly converted to:
Hi there
”Some quote”
where the first quote on "Some quote" is being treated as a closing quote.
This PR fixes that by inserting a space into allText every time we see a paragraph node, then skipping over the inserted spaces when we need to keep track of indexes. That feels slightly clumsy, but it's a targeted way to fix this bug without changing the other behavior of this plugin.
Test Plan
Three new unit tests are introduced which fail without this change and succeed with it.
Summary
v2.1.0 fixed smart quotes around links and inline code by concatenating all text into one string (
allText
) and converting that withretext-smartypants
.That introduced a small regression. Quotes at the start of a paragraph may be merged with another paragraph, which
retext-smartypants
will no longer recognize as opening quotes. For instance:is incorrectly converted to:
where the first quote on "Some quote" is being treated as a closing quote.
This PR fixes that by inserting a space into
allText
every time we see aparagraph
node, then skipping over the inserted spaces when we need to keep track of indexes. That feels slightly clumsy, but it's a targeted way to fix this bug without changing the other behavior of this plugin.Test Plan