From ee186f69641b6ce7528a56d15ae534df923ec05f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 11 Dec 2020 21:05:26 +0200 Subject: [PATCH] Default to Python highlighting for '::' code blocks. Other languages can be set like '.. code-block:: c'. --- peps/converters.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/peps/converters.py b/peps/converters.py index a2aed2863..8adaf077f 100644 --- a/peps/converters.py +++ b/peps/converters.py @@ -157,14 +157,15 @@ def convert_pep_page(pep_number, content): div = pep_content.new_tag('div') div['class'] = ['highlight'] cb.wrap(div) - # Highlight existing pure-Python PEPs - if int(pep_number) in PURE_PYTHON_PEPS: - literal_blocks = pep_content.find_all('pre', class_='literal-block') - for lb in literal_blocks: - block = lb.string - if block: - highlighted = highlight(block, PythonLexer(), HtmlFormatter()) - lb.replace_with(BeautifulSoup(highlighted).html.body.div) + + # Default to Python highlighting for '::' code blocks. + # Other languages can be set like '.. code-block:: c'. + literal_blocks = pep_content.find_all('pre', class_='literal-block') + for lb in literal_blocks: + block = lb.string + if block: + highlighted = highlight(block, PythonLexer(), HtmlFormatter()) + lb.replace_with(BeautifulSoup(highlighted, 'lxml').html.body.div) pep_href_re = re.compile(r'pep-(\d+)\.html')