Skip to content

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
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