Skip to content
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

smarty: Add a special case for 's at the beginning of the token #1348

Merged
merged 1 commit into from
May 22, 2023

Conversation

mitya57
Copy link
Collaborator

@mitya57 mitya57 commented May 17, 2023

When 's is not preceded by anything, it probably means that it comes after some HTML tag, so it should be converted to a closing quote.

The reference Perl implementation makes the close_class optional and adds a lookahead check for (\s|s\b) when close_class was not matched:

# Single closing quotes:
s {
    ($close_class)?
    '
    (?(1)|          # If $1 captured, then do nothing;
      (?=\s | s\b)  # otherwise, positive lookahead for a whitespace
    )               # char or an 's' at a word ending position. This
                    # is a special case to handle something like:
                    # "<i>Custer</i>'s Last Stand."
} {$1&#8217;}xgi;

Let's copy that behavior by removing closeClass lookbehind check from closingSingleQuotesRegex2.

Fixes #1305.

When 's is not preceded by anything, it probably means that it comes
after some HTML tag, so it should be converted to a closing quote.

The reference Perl implementation makes the close_class optional and
adds a lookahead check for (\s|s\b) when close_class was not matched.

Let's copy that behavior by removing closeClass lookbehind check from
closingSingleQuotesRegex2.

Fixes Python-Markdown#1305.
@waylan waylan merged commit dba8025 into Python-Markdown:master May 22, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SmartyPants: Apostrophes at the start of leading contractions
2 participants