This repository was archived by the owner on Mar 25, 2022. It is now read-only.
Remove URL quoting from refs before passing to Sphinx#158
Merged
Conversation
Sphinx allows refs with spaces etc, and in fact autogenerates them with the command [`autosectionlabel`][]. So if you put a: ```markdown [Link 1](<some ref>) [Link 2](<https://foo.com/bar baz>) ``` Then the links will be `some%20ref` and `https://foo.com/bar%20baz`. We want to keep the URL quoting for external references, but if we're passing it as `:any:` to Sphinx we need to unquote so Sphinx can find the correct reference, the `<some ref>` should map to: ```rst :ref:`some ref` ``` [`autosectionlabel`](https://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html) Fixes: readthedocs#155
b26815c to
ec0ada9
Compare
gibfahn
commented
Jun 14, 2019
| if not url_check.scheme and not url_check.fragment: | ||
| wrap_node = addnodes.pending_xref( | ||
| reftarget=destination, | ||
| reftarget=unquote(destination), |
Contributor
Author
There was a problem hiding this comment.
This is the only actual change.
Contributor
Author
|
@ericholscher sorry for the direct ping, but would you mind taking a look at this? I think it should be uncontroversial. I've been using it (via a Full patch code in case anyone else needs to do the same: Patch script: # Generate patch with:
cp .venv/lib/python3.*/site-packages/recommonmark/parser.py parser.py
# Edit ./parser.py to apply the change here
# Generate patch
diff -u .venv/lib/python3.*/site-packages/recommonmark/parser.py parser.py > parser.py.patch
# Commit ./parser.py.patch, delete ./parser.py
# Apply patch as part of your Makefile/setup.py:
patch --forward \
.venv/lib/python3.*/site-packages/recommonmark/parser.py \
< parser.py.patch \
|| trueGenerated patch: --- .venv/lib/python3.7/site-packages/recommonmark/parser.py 2019-05-16 11:29:29.045060000 +0200
+++ parser.py 2019-05-23 16:21:31.172900496 +0200
@@ -11,9 +11,9 @@
from warnings import warn
if sys.version_info < (3, 0):
- from urlparse import urlparse
+ from urlparse import urlparse, unquote
else:
- from urllib.parse import urlparse
+ from urllib.parse import urlparse, unquote
__all__ = ['CommonMarkParser']
@@ -152,7 +152,7 @@
url_check = urlparse(destination)
if not url_check.scheme and not url_check.fragment:
wrap_node = addnodes.pending_xref(
- reftarget=destination,
+ reftarget=unquote(destination),
reftype='any',
refdomain=None, # Added to enable cross-linking
refexplicit=True,
|
Member
|
Looks good, no worries on the direct ping 👍 |
Member
|
I will try and get a release out here soon. |
Contributor
Author
|
Thank you! |
Contributor
Author
@ericholscher any chance of a release? If there's anything I could do to help with said release let me know. |
Member
|
I just shipped 0.6.0 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sphinx allows refs with spaces etc, and in fact autogenerates them with
the command
autosectionlabel.So if you put a:
Then the links will be
some%20refandhttps://foo.com/bar%20baz.We want to keep the URL quoting for external references, but if we're
passing it as
:any:to Sphinx we need to unquote so Sphinx can findthe correct reference, the
<some ref>should map to:Fixes: #155