Skip to content

Commit

Permalink
Fix URLs with dots
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Sep 16, 2019
1 parent 4ed53f8 commit 3ded25b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/sphinxext/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def rc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
relsource = source.split('/docs/', 1)
if len(relsource) == 1:
return [], []
cat = text.split('.')[0] # show category because there are issues highlighting dots
levels = relsource[1].count('/') # distance to 'docs' folder
refuri = ('../' * levels +
f'en/latest/rctools.html?highlight={cat}#proplotrc-file')
f'en/latest/rctools.html?highlight={text}#proplotrc-file/')
# note trailing slash is critical for URLs with dots!
# see: https://stackoverflow.com/a/38800236/4970632

ref = nodes.reference(rawtext, rendered, refuri=refuri)
node_list = [nodes.literal('', '', ref)]
Expand Down

0 comments on commit 3ded25b

Please sign in to comment.