Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the output a literal.
  • Loading branch information
ezio-melotti committed Oct 9, 2022
commit e194b3e0ccc690c1419d304513bbd07c9950d892
6 changes: 5 additions & 1 deletion _extensions/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ def setup(app):

def autolink(pattern):
def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
Comment thread
ezio-melotti marked this conversation as resolved.
Outdated
"""Combine literal + reference (unless the text is prefixed by a !)."""
if " " in text:
url_text = urllib.parse.quote(f"{text}")
Comment thread
ezio-melotti marked this conversation as resolved.
Outdated
else:
url_text = text
url = pattern % (url_text,)
Comment thread
ezio-melotti marked this conversation as resolved.
Outdated
node = nodes.reference(rawtext, text, refuri=url, **options)
node = nodes.literal('', text.lstrip('!'), **options)
Comment thread
ezio-melotti marked this conversation as resolved.
Outdated
# don't create a reference if the text starts with !
if not text.startswith('!'):
node = nodes.reference('', '', node, refuri=url, **options)
return [node], []

return role
2 changes: 1 addition & 1 deletion internals/parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ parser (the one used by the interpreter) just execute: ::

make regen-pegen

using the :file:`Makefile` in the main directory. If you are on Windows you can
using the :cpy-file:`!Makefile` in the main directory. If you are on Windows you can
use the Visual Studio project files to regenerate the parser or to execute: ::

./PCbuild/build.bat --regen
Expand Down