-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Terminal double quote is transformed to open double quote character #12
Comments
Heya! Definitely possible. It‘s been ages since I looked into this algorithm. Here’s the code: retext-smartypants/lib/index.js Line 307 in 070853f
The SmartyPants pl code seems to be around L442 there. As you have that running, perhaps you are able to add some |
Thanks. Normally, if you write say retext-smartypants/lib/index.js Lines 354 to 361 in 070853f
But, in my example {
type: 'PunctuationNode',
value: '.',
position: {
start: { line: 1, column: 17, offset: 16 },
end: { line: 1, column: 18, offset: 17 }
}
} The part of the original Perl that transforms that character is here: my $close_class = qr![^\ \t\r\n\[\{\(\-]!;
# Double closing quotes:
s {
($close_class)?
"
(?(1)|(?=\s)) # If $1 captured, then do nothing;
# if not, then make sure the next char is whitespace.
} {$1”}xg; The logic between the two is not equivalent.
Note there is a second place where the Perl code outputs a double closing quote, which is: # Special case if the very first character is a quote
# followed by punctuation at a non-word-break. Close the quotes by brute force:
s/^"(?=$punct_class\B)/”/; In retext-smartypants that's here, but again the translation differs. I don't think retext-smartypants/lib/index.js Lines 321 to 329 in 070853f
I think anywhere the Perl code uses |
nice research! want to work on a PR, test out whether that change is enough? |
I interpret the meaning of if (
next &&
nextNext &&
(next.type === 'PunctuationNode' || next.type === 'SymbolNode') &&
((next.type === 'WordNode' && nextNext.type === 'WordNode') ||
(next.type !== 'WordNode' && nextNext.type !=='WordNode'))
) But there's a weird hitch where non-word at the end of the string matches (
Translating that, I think it would be: if (
next &&
(next.type === 'PunctuationNode' || next.type === 'SymbolNode') &&
(!nextNext || nextNext.type !== 'WordNode')
) Here are some test cases:
The third test case still fails because repeated occurrences of the same symbol are combined into a single node. How do you recommend we get the desired behavior? Something with |
thanks, released! https://github.com/retextjs/retext-smartypants/releases/tag/6.1.1 I don’t really care for the |
Initial checklist
Affected packages and versions
6.1.0
Steps to reproduce
I am transforming text that contains a parenthetical quote written in quotation marks, like:
("This is a test.")
. The output contains two opening double quotes. The second quote should be a closing double quote.As a more minimal input
("A.")
reproduces the issue. Interestingly, removing the period causes it to output correctly.I've encoded the resulting output as hex-encoded-UTF-8 to minimize the chance of macOS helpfully correcting anything for me.
The above code outputs
28e2809c412ee2809c29
, showing that both the quotation marks were transformed to the same sequence,e2809c
, an opening double quote.SmartyPants 1.5.1 transforms the text correctly:
Affected runtime and version
[email protected]
The text was updated successfully, but these errors were encountered: