Skip to content

Commit ee186f6

Browse files
committed
Default to Python highlighting for '::' code blocks.
Other languages can be set like '.. code-block:: c'.
1 parent a91ec43 commit ee186f6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

peps/converters.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,15 @@ def convert_pep_page(pep_number, content):
157157
div = pep_content.new_tag('div')
158158
div['class'] = ['highlight']
159159
cb.wrap(div)
160-
# Highlight existing pure-Python PEPs
161-
if int(pep_number) in PURE_PYTHON_PEPS:
162-
literal_blocks = pep_content.find_all('pre', class_='literal-block')
163-
for lb in literal_blocks:
164-
block = lb.string
165-
if block:
166-
highlighted = highlight(block, PythonLexer(), HtmlFormatter())
167-
lb.replace_with(BeautifulSoup(highlighted).html.body.div)
160+
161+
# Default to Python highlighting for '::' code blocks.
162+
# Other languages can be set like '.. code-block:: c'.
163+
literal_blocks = pep_content.find_all('pre', class_='literal-block')
164+
for lb in literal_blocks:
165+
block = lb.string
166+
if block:
167+
highlighted = highlight(block, PythonLexer(), HtmlFormatter())
168+
lb.replace_with(BeautifulSoup(highlighted, 'lxml').html.body.div)
168169

169170
pep_href_re = re.compile(r'pep-(\d+)\.html')
170171

0 commit comments

Comments
 (0)