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

Apostrophes in contractions are not converted to right single quote #39

Closed
bryanforbes opened this issue Nov 28, 2019 · 10 comments · Fixed by #88
Closed

Apostrophes in contractions are not converted to right single quote #39

bryanforbes opened this issue Nov 28, 2019 · 10 comments · Fixed by #88
Labels
enhancement New feature or request help wanted Extra attention is needed stale

Comments

@bryanforbes
Copy link

bryanforbes commented Nov 28, 2019

For the following text:

I'm going to see my mother. She's very nice.

Currently, ' is not converted to ’ for contractions when the typography extension is enabled, but smartypants does. I would expect the output to be:

I’m going to see my mother. She’s very nice.
@bryanforbes bryanforbes changed the title Contractions are not converted to right single quote Apostrophes in contractions are not converted to right single quote Nov 28, 2019
@yuin yuin added the enhancement New feature or request label Nov 29, 2019
@sungchang-ha
Copy link

It appears that the single quote (identical to apostrophe in Markdown input) is not converted as intended in the following case.

Source text (note the period at the end):

'sample'.

Expected:

‘sample’.

Actual result:

‘sample'.

Let me know if I should create a separate issue for this.

@yuin
Copy link
Owner

yuin commented Dec 3, 2019

@bryanforbes Typographer extension is just a typographer extension is not SmartyPants exntension. Typographer extension does not support your case.

@sungchang-ha I can not reproduce this. 'sample'. is converted to ‘sample’. in my environment.

@sungchang-ha
Copy link

@yuin I should've provided the test string as-is, which I edited to no avail.

It appears that the combination of inline styles (bold, italic, etc.) and the adjacent punctuation mark causes the issue. Test environment is Goldmark 1.1.8 and the made-up test string is shown below:

  • Markdown: '*en-US*'/'**javascript**', '*sample*'.
  • Expected: &lsquo;<em>en-US</em>&rsquo;/&lsquo;<strong>javascript</strong>&rsquo;, &lsquo;<em>sample<em>&rsquo;.
  • Current: &lsquo;<em>en-US</em>'/'<strong>javascript</strong>', &lsquo;<em>sample</em>'.

Removing either of the inline style or the adjacent punctuation mark makes it rendered as quotes.

@yuin
Copy link
Owner

yuin commented Dec 3, 2019

@sungchang-ha Reasonable. Typographer extension is implemented with same algorithm as Emphasis and strong emphasis defined in CommonMark. Left flanking is converted into &lsquo; and Right flanking is converted into &rsquo; . This is a limitation in this algorithm.

I'm not usually writing English, so this functionalities has low priority for me.
I welcome PR with enhancement of typographer.

@yuin yuin added the help wanted Extra attention is needed label Dec 7, 2019
@bryanforbes
Copy link
Author

Typographer extension does not support your case.

Do you mean that converting apostrophes to single right quote will not be supported ever, or that converting them is currently unsupported?

@yuin
Copy link
Owner

yuin commented Dec 12, 2019

@bryanforbes Converting them is currently unsupported. As wrote above, I'm not usually writing English and honestly say I never used this functionality.

I do not have so much time for this project, so I'm going to use the time for better supporting CJK environment instead of typographer that I have never used.

I welcome PR that enhances typographer(or adds complete SmartyPants extension).

@stale
Copy link

stale bot commented Jan 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@rgov
Copy link

rgov commented May 18, 2020

Before trying to fix the cases where Typographer doesn't work properly, is an inline parser the correct model for this transformation? To fix this, we would need to have the plain text without formatting. E.g., **This is** a [test][]. should yield This is a test..

@yuin
Copy link
Owner

yuin commented May 19, 2020

@rgov
Probably not. There's no efficient and 'works perfectly' model in goldmark right now for this.

goldmark is an extensible markdown parser, so we can not know about information of user-assigned extension(ast nodes, syntax, html output, etc).

Furthermore, users can remove or replace built-in parsers and renderers. If users remove a built-in emphasis parser, your example should yield **this is** a test . If users replace built-in emphasis renderer with their own renderer that render ** as IMPORTANT{}, your example should yield IMPORTANT{this is} a test.
These are extreme cases though.

I think parsing html output is the only way that you perfectly apply smartypants substitutions.
If we give special treatment for smartypants, we are probably able to find more efficient way. But I'm not willing to give such treatment for English specific functionalities like smartypants.

yuin added a commit that referenced this issue May 21, 2020
@yuin
Copy link
Owner

yuin commented May 21, 2020

I've tried to fix this in 3393022.
But I'm not familiar with English, Could anyone confirm whether this is fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants