diff options
10 files changed, 25 insertions, 16 deletions
diff --git a/docutils/docs/user/config.txt b/docutils/docs/user/config.txt index 95154186b..4617c6449 100644 --- a/docutils/docs/user/config.txt +++ b/docutils/docs/user/config.txt @@ -743,6 +743,12 @@ _`pep_base_url` Default: "http://www.python.org/peps/". Option: ``--pep-base-url``. +_`pep_file_url_template` + Template for PEP file part of URL, interpolated with the PEP + number and appended to pep_base_url_. + + Default: "pep-%04d". Option: ``--pep-file-url``. + _`raw_enabled` Enable or disable the "raw_" directive. A "warning" system message (including the directive text) is inserted instead. (See diff --git a/docutils/docutils/parsers/rst/__init__.py b/docutils/docutils/parsers/rst/__init__.py index be49161a0..d2e68e349 100644 --- a/docutils/docutils/parsers/rst/__init__.py +++ b/docutils/docutils/parsers/rst/__init__.py @@ -96,6 +96,9 @@ class Parser(docutils.parsers.Parser): ['--pep-base-url'], {'metavar': '<URL>', 'default': 'http://www.python.org/dev/peps/', 'validator': frontend.validate_url_trailing_slash}), + ('Template for PEP file part of URL. (default "pep-%04d")', + ['--pep-file-url-template'], + {'metavar': '<URL>', 'default': 'pep-%04d'}), ('Recognize and link to standalone RFC references (like "RFC 822").', ['--rfc-references'], {'action': 'store_true', 'validator': frontend.validate_boolean}), diff --git a/docutils/docutils/parsers/rst/roles.py b/docutils/docutils/parsers/rst/roles.py index 554e1f441..b6ed9fdb1 100644 --- a/docutils/docutils/parsers/rst/roles.py +++ b/docutils/docutils/parsers/rst/roles.py @@ -266,7 +266,8 @@ def pep_reference_role(role, rawtext, text, lineno, inliner, prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] # Base URL mainly used by inliner.pep_reference; so this is correct: - ref = inliner.document.settings.pep_base_url + inliner.pep_url % pepnum + ref = (inliner.document.settings.pep_base_url + + inliner.document.settings.pep_file_url_template % pepnum) set_classes(options) return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref, **options)], [] diff --git a/docutils/docutils/parsers/rst/states.py b/docutils/docutils/parsers/rst/states.py index 64ab89910..2eab7fe5d 100644 --- a/docutils/docutils/parsers/rst/states.py +++ b/docutils/docutils/parsers/rst/states.py @@ -915,8 +915,6 @@ class Inliner: else: # not a valid scheme raise MarkupMismatch - pep_url = 'pep-%04d.html' - def pep_reference(self, match, lineno): text = match.group(0) if text.startswith('pep-'): @@ -925,7 +923,8 @@ class Inliner: pepnum = int(match.group('pepnum2')) else: raise MarkupMismatch - ref = self.document.settings.pep_base_url + self.pep_url % pepnum + ref = (self.document.settings.pep_base_url + + self.document.settings.pep_file_url_template % pepnum) unescaped = unescape(text, 0) return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)] diff --git a/docutils/docutils/writers/pep_html/template.txt b/docutils/docutils/writers/pep_html/template.txt index 6f96977e8..4b421af68 100644 --- a/docutils/docutils/writers/pep_html/template.txt +++ b/docutils/docutils/writers/pep_html/template.txt @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- This HTML is auto-generated. DO NOT EDIT THIS FILE! If you are writing a new -PEP, see http://www.python.org/peps/pep-0001.html for instructions and links +PEP, see http://www.python.org/dev/peps/pep-0001 for instructions and links to templates. DO NOT USE THIS HTML FILE AS YOUR TEMPLATE! --> <head> diff --git a/docutils/test/functional/expected/standalone_rst_html4css1.html b/docutils/test/functional/expected/standalone_rst_html4css1.html index 53ffe2908..d1911dfdf 100644 --- a/docutils/test/functional/expected/standalone_rst_html4css1.html +++ b/docutils/test/functional/expected/standalone_rst_html4css1.html @@ -175,7 +175,7 @@ inline markup is also possible (although exceedingly ugly!) in <em>re</em><tt cl (generated by processing errors; this one is intentional). Here is a reference to the <a class="reference" href="#doctitle">doctitle</a> and the <a class="reference" href="#subtitle">subtitle</a>.</p> <p>The default role for interpreted text is <cite>Title Reference</cite>. Here are -some explicit interpreted text roles: a PEP reference (<a class="reference" href="http://www.python.org/dev/peps/pep-0287.html">PEP 287</a>); an +some explicit interpreted text roles: a PEP reference (<a class="reference" href="http://www.python.org/dev/peps/pep-0287">PEP 287</a>); an RFC reference (<a class="reference" href="http://www.faqs.org/rfcs/rfc2822.html">RFC 2822</a>); a <sub>subscript</sub>; a <sup>superscript</sup>; and explicit roles for <em>standard</em> <strong>inline</strong> <tt class="docutils literal"><span class="pre">markup</span></tt>.</p> diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex index 433b8d400..4e3b7d020 100644 --- a/docutils/test/functional/expected/standalone_rst_latex.tex +++ b/docutils/test/functional/expected/standalone_rst_latex.tex @@ -312,7 +312,7 @@ inline markup is also possible (although exceedingly ugly!) in \emph{re}\texttt{ reference to the \href{\#doctitle}{doctitle} and the \href{\#subtitle}{subtitle}. The default role for interpreted text is \titlereference{Title Reference}. Here are -some explicit interpreted text roles: a PEP reference (\href{http://www.python.org/dev/peps/pep-0287.html}{PEP 287}); an +some explicit interpreted text roles: a PEP reference (\href{http://www.python.org/dev/peps/pep-0287}{PEP 287}); an RFC reference (\href{http://www.faqs.org/rfcs/rfc2822.html}{RFC 2822}); a $_{subscript}$; a $^{superscript}$; and explicit roles for \emph{standard} \textbf{inline} \texttt{markup}. diff --git a/docutils/test/functional/expected/standalone_rst_pseudoxml.txt b/docutils/test/functional/expected/standalone_rst_pseudoxml.txt index ed4562462..2dfef4b27 100644 --- a/docutils/test/functional/expected/standalone_rst_pseudoxml.txt +++ b/docutils/test/functional/expected/standalone_rst_pseudoxml.txt @@ -470,7 +470,7 @@ Title Reference . Here are some explicit interpreted text roles: a PEP reference ( - <reference refuri="http://www.python.org/dev/peps/pep-0287.html"> + <reference refuri="http://www.python.org/dev/peps/pep-0287"> PEP 287 ); an RFC reference ( diff --git a/docutils/test/test_parsers/test_rst/test_interpreted.py b/docutils/test/test_parsers/test_rst/test_interpreted.py index aa342d573..95763868e 100755 --- a/docutils/test/test_parsers/test_rst/test_interpreted.py +++ b/docutils/test/test_parsers/test_rst/test_interpreted.py @@ -182,7 +182,7 @@ totest['references'] = [ """\ <document source="test data"> <paragraph> - <reference refuri="http://www.python.org/dev/peps/pep-0000.html"> + <reference refuri="http://www.python.org/dev/peps/pep-0000"> PEP 0 """], ["""\ diff --git a/docutils/test/test_readers/test_pep/test_inline_markup.py b/docutils/test/test_readers/test_pep/test_inline_markup.py index 80b100593..6dd2ab87b 100755 --- a/docutils/test/test_readers/test_pep/test_inline_markup.py +++ b/docutils/test/test_readers/test_pep/test_inline_markup.py @@ -30,10 +30,10 @@ and RFC 2822 (which obsoletes RFC822 and RFC-733). <document source="test data"> <paragraph> See \n\ - <reference refuri="http://www.python.org/dev/peps/pep-0287.html"> + <reference refuri="http://www.python.org/dev/peps/pep-0287"> PEP 287 ( - <reference refuri="http://www.python.org/dev/peps/pep-0287.html"> + <reference refuri="http://www.python.org/dev/peps/pep-0287"> pep-0287.txt ), and \n\ @@ -61,7 +61,7 @@ RFC <paragraph> References split across lines: <paragraph> - <reference refuri="http://www.python.org/dev/peps/pep-0287.html"> + <reference refuri="http://www.python.org/dev/peps/pep-0287"> PEP 287 <paragraph> @@ -72,18 +72,18 @@ RFC ["""\ Test PEP-specific implicit references before a URL: -PEP 287 (http://www.python.org/dev/peps/pep-0287.html), RFC 2822. +PEP 287 (http://www.python.org/dev/peps/pep-0287), RFC 2822. """, """\ <document source="test data"> <paragraph> Test PEP-specific implicit references before a URL: <paragraph> - <reference refuri="http://www.python.org/dev/peps/pep-0287.html"> + <reference refuri="http://www.python.org/dev/peps/pep-0287"> PEP 287 ( - <reference refuri="http://www.python.org/dev/peps/pep-0287.html"> - http://www.python.org/dev/peps/pep-0287.html + <reference refuri="http://www.python.org/dev/peps/pep-0287"> + http://www.python.org/dev/peps/pep-0287 ), \n\ <reference refuri="http://www.faqs.org/rfcs/rfc2822.html"> RFC 2822 |
