-
Notifications
You must be signed in to change notification settings - Fork 873
smarty: double sets of quotes not working at end #1514
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
Comments
That doesn't seem like a bad solution.
What do you mean by this? |
After posting the issue, I went back to what I was working on and realized my solution didn't work when wrapped in html tags, for example:
In this case, the closing double quote is not at the end of the string and is not followed by whitespace. So adding another regex similar to doubleQuoteSetsRe might be needed. None of the other regex variables use |
I see, that makes sense. It may be that those tags are converted to placeholders creating a non-word boundary. I think it will need some investigation. I haven't taken a close look at the current pattern and its intentions. I'm sure there are some tricky cases where checking for space following the quote was important, I just don't know what all the cases are right now. |
It seems situations like this are also problematic (non-word boundaries):
My initial thought is it needs a non-word boundary check, but that might blow up some other cases. Definitely needs some further investigation to be sure. Generally, IIRC, smarty quotes can be difficult to always get right the way we do them. Personally, I often turn off smarty quotes for these reasons, but I understand the desire to improve them and get them right (or at least better). |
I don't think a word boundary check would be correct, but maybe a not word check |
Hm, what exactly change did you try? I have just tried this: --- a/markdown/extensions/smarty.py
+++ b/markdown/extensions/smarty.py
@@ -142,7 +142,7 @@ decadeAbbrRe = r"(?<!\w)'(?=\d{2}s)"
openingDoubleQuotesRegex = r'%s"(?=\w)' % openingQuotesBase
# Double closing quotes:
-closingDoubleQuotesRegex = r'"(?=\s)'
+closingDoubleQuotesRegex = r'"(?=\s|\W|$)'
closingDoubleQuotesRegex2 = '(?<=%s)"' % closeClass
# Get most opening single quotes: but it does break one of the tests:
|
@mitya57 You are correct. I ran |
Thank you both for the suggestions. I can't think of a way to modify closingDoubleQuotesRegex without breaking the existing tests. And modifying closingDoubleQuotesRegex2 won't work either, because if a preceding single quote has already been replaced, closeClass will no longer match (due to |
The following example renders incorrectly:
The output is:
The
“
at the end of this example should be”
.The quote marks were replaced in this order:
Unfortunately:
"
is not followed by a space (it's the last character of the string, which is stripped prior to replacement).SubstituteTextPattern.handleMatch()
contains\u0003
before the"
).One possible way to fix this issue might be to change closingDoubleQuotesRegex to
r'"(?=\s|$)'
(i.e., double quote followed by whitespace or end of string). However that doesn't work in general, so a special case is likely needed.The text was updated successfully, but these errors were encountered: