PEP 1: Make `text/x-rst` the default for the Content-Type header (#2355)

This commit is contained in:
CAM Gerlach 2022-02-24 14:45:26 -06:00 committed by GitHub
parent 9270420cf2
commit d795805141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View File

@ -596,7 +596,7 @@ optional and are described below. All other headers are required.
Status: <Draft | Active | Accepted | Provisional | Deferred | Rejected | Status: <Draft | Active | Accepted | Provisional | Deferred | Rejected |
Withdrawn | Final | Superseded> Withdrawn | Final | Superseded>
Type: <Standards Track | Informational | Process> Type: <Standards Track | Informational | Process>
* Content-Type: <text/x-rst | text/plain> * Content-Type: text/x-rst
* Requires: <pep numbers> * Requires: <pep numbers>
Created: <date created on, in dd-mmm-yyyy format> Created: <date created on, in dd-mmm-yyyy format>
* Python-Version: <version number> * Python-Version: <version number>
@ -649,11 +649,9 @@ The Type header specifies the type of PEP: Standards Track,
Informational, or Process. Informational, or Process.
The format of a PEP is specified with a Content-Type header. The format of a PEP is specified with a Content-Type header.
Valid values are ``text/plain`` for plaintext PEPs (see :pep:`9`) All PEPs must use reStructuredText (see :pep:`12`),
and ``text/x-rst`` for reStructuredText PEPs (see :pep:`12`). and have a value of ``text/x-rst``, the default.
All new and active PEPs must use reStructuredText, but for backwards Previously, plaintext PEPs used ``text/plain`` (see :pep:`9`).
compatibility, plain text is currently still the default if no
Content-Type header is present.
The Created header records the date that the PEP was assigned a The Created header records the date that the PEP was assigned a
number, while Post-History is used to record the dates of when new number, while Post-History is used to record the dates of when new

View File

@ -6,6 +6,7 @@ PEP-Delegate: <PEP delegate's real name>
Discussions-To: <REQUIRED: URL of current canonical discussion thread> Discussions-To: <REQUIRED: URL of current canonical discussion thread>
Status: <REQUIRED: Draft | Active | Accepted | Provisional | Deferred | Rejected | Withdrawn | Final | Superseded> Status: <REQUIRED: Draft | Active | Accepted | Provisional | Deferred | Rejected | Withdrawn | Final | Superseded>
Type: <REQUIRED: Standards Track | Informational | Process> Type: <REQUIRED: Standards Track | Informational | Process>
Content-Type: text/x-rst
Requires: <pep numbers> Requires: <pep numbers>
Created: <date created on, in dd-mmm-yyyy format> Created: <date created on, in dd-mmm-yyyy format>
Python-Version: <version number> Python-Version: <version number>

View File

@ -260,7 +260,7 @@ def fixfile(inpath, input_lines, outfile):
v = date v = date
elif k.lower() in ('content-type',): elif k.lower() in ('content-type',):
url = PEPURL % 9 url = PEPURL % 9
pep_type = v or 'text/plain' pep_type = v or 'text/x-rst'
v = '<a href="%s">%s</a> ' % (url, escape(pep_type)) v = '<a href="%s">%s</a> ' % (url, escape(pep_type))
elif k.lower() == 'version': elif k.lower() == 'version':
if v.startswith('$' 'Revision: ') and v.endswith(' $'): if v.startswith('$' 'Revision: ') and v.endswith(' $'):
@ -569,7 +569,7 @@ def fix_rst_pep(inpath, input_lines, outfile):
def get_pep_type(input_lines): def get_pep_type(input_lines):
""" """
Return the Content-Type of the input. "text/plain" is the default. Return the Content-Type of the input. "text/x-rst" is the default.
Return ``None`` if the input is not a PEP. Return ``None`` if the input is not a PEP.
""" """
pep_type = None pep_type = None
@ -579,11 +579,11 @@ def get_pep_type(input_lines):
# End of the RFC 2822 header (first blank line). # End of the RFC 2822 header (first blank line).
break break
elif line.startswith('content-type: '): elif line.startswith('content-type: '):
pep_type = line.split()[1] or 'text/plain' pep_type = line.split()[1] or 'text/x-rst'
break break
elif line.startswith('pep: '): elif line.startswith('pep: '):
# Default PEP type, used if no explicit content-type specified: # Default PEP type, used if no explicit content-type specified:
pep_type = 'text/plain' pep_type = 'text/x-rst'
return pep_type return pep_type