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

Smart quotes incorrectly converted before a link #4864

Closed
mapio opened this issue Apr 19, 2018 · 5 comments
Closed

Smart quotes incorrectly converted before a link #4864

mapio opened this issue Apr 19, 2018 · 5 comments

Comments

@mapio
Copy link

mapio commented Apr 19, 2018

When converting something like

bell'`esempio <http://example.net/>`_ 

to HTML you get

bell”<a class="reference external" href="http://example.net/">esempio</a>

where a smart quote takes the place of the single quote (that is the apostrophe, quite common in italian, for example).

This can be avoided if smartquotes = False is added to the configuration, in such case the conversion becomes

bell'<a class="reference external" href="http://example.net/">esempio</a>

as expected (and correct).

@jfbu
Copy link
Contributor

jfbu commented Apr 20, 2018

Thanks, can you report it upstream at Docutils with test file

bell'`esempio <http://example.net/>`_ 

and

rst2html.py --smart-quotes=on --language=it testquote.rst testquote.html

(or without the --language also).

@mapio
Copy link
Author

mapio commented Apr 23, 2018

I just did it https://sourceforge.net/p/docutils/bugs/343/

@mapio mapio closed this as completed Apr 23, 2018
@mapio
Copy link
Author

mapio commented Apr 29, 2018

As answered on the Docutils bug tracker https://sourceforge.net/p/docutils/bugs/343/#57bf (copied here for convenience of Sphinx users):

This is actually a documented limitation of the "smartquotes" feature:

A single quote before a link is detected as a closing single quote.

The core problem is, that "smartquotes" cannot
distinguish a single quote from an apostrophe. You will see this also with
apostrophes at the end of a word, apostrophes inside a word if "smartquotes"
are activate because of escaped spaces, and with other inline markup.

This is masked in English because the single quote is converted to
RIGHT SINGLE QUOTATION MARK () and, according to the Unicode Standard,
"this is the preferred character to use for apostrophe".

As a result, smartquotes must be uses with special caution (or not at all)
with languages where the closing single quote glyph differs from the
apostrophe glyph.

Workarounds include:

a) disable smartquotes for languages where the closing single quote
differs from the apostrophe,
b) use literal Unicode character (bell’esempio) for apostrophe,
c) escape the ASCII APOSTROPHE character to prevent "education"
(bell\'esempio).
d) set custom smart-quotes-locale with RIGHT SINGLE QUOTATION MARK () for
apostrophe and literal Unicode characters for single quotes,

IMO, workaround a) would be the safe thing to do for Sphinx.

@jfbu
Copy link
Contributor

jfbu commented Apr 30, 2018

It is probably best in this case to input the correct literal Unicode character for the language.

To disable smartquotes for a specific language, say italian you can use the smartquotes_excludes config value in conf.py. For example

smartquotes_excludes = {'languages': ['ja', 'it'], 'builders': ['man', 'text']}

Each entry gives a sufficient condition, so the above excludes smart quotes

  • for Japanese, (all targets)

  • for Italian, (all targets)

  • for man pages, (all languages)

  • for text target, (all languages).

Apart from Italian language, the above is already default.

@mapio
Copy link
Author

mapio commented Mar 6, 2019

I find the d) fix more interesting, since it gives you the right "smart" quotes.

Just make a file named docutils.conf in the same dir where you have conf.py with the following content:

[restructuredtext parser]
smartquotes-locales: it: “”‘’

where the four charachters are the right/left single/double unicode quotes.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants