Skip to content

Commit

Permalink
Implement review comments, and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilevkivskyi authored and hugovk committed Sep 21, 2020
1 parent e340ac1 commit fba9086
Show file tree
Hide file tree
Showing 5 changed files with 671 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ django-waffle==0.14
djangorestframework==3.8.2
django-filter==1.1.0

pygments==2.1.3
pygments==2.1.3 # This will be not needed when PEPs are moved to RtD.
11 changes: 8 additions & 3 deletions peps/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
PEP_TEMPLATE = 'pages/pep-page.html'
pep_url = lambda num: 'dev/peps/pep-{}/'.format(num)

# To simplify syntax highlighting, all literal blocks (those produced by ::)
# in the following PEPs will be automatically highlighted using Python lexer.
# PEP editors/authors could make simple PRs extending this list.
# This will be not needed when PEPs are moved to RtD and all code blocks are
# formatted using .. code:: language.
PURE_PYTHON_PEPS = [483, 484, 526]

def get_peps_last_updated():
Expand Down Expand Up @@ -145,16 +150,16 @@ def convert_pep_page(pep_number, content):
# Fix PEP links
pep_content = BeautifulSoup(data['content'], 'lxml')
body_links = pep_content.find_all("a")
# Fix hihglighting code
code_blocks = pep_content.find_all("pre", class_="code")
# Fix highlighting code
code_blocks = pep_content.find_all('pre', class_='code')
for cb in code_blocks:
del cb['class']
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")
literal_blocks = pep_content.find_all('pre', class_='literal-block')
for lb in literal_blocks:
block = lb.string
if block:
Expand Down
Loading

0 comments on commit fba9086

Please sign in to comment.