Skip to content

Commit

Permalink
fix: allow spaces in review references
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Apr 11, 2021
1 parent 9d71956 commit 472a9be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ can be used as follows:
:pdg-review:`QCD; p5`
:pdg-listing:`QCD; p5`
:pdg-review:`QCD; p5`
:pdg-review:`PDG2015; Quark Model; p.2`
```

which will render in the HTML pages as:
Expand All @@ -73,8 +71,6 @@ which will render in the HTML pages as:
>
> [PDG2020, §QCD, p.5](https://pdg.lbl.gov/2020/reviews/rpp2020-rev-qcd.pdf#page=5)
>
> [PDG2020, §QCD, p.5](https://pdg.lbl.gov/2020/reviews/rpp2020-rev-qcd.pdf#page=5)
>
> [PDG2018](https://pdg.lbl.gov/2018/listings/rpp2018-list-K-zero.pdf)
> [PDG2015, §Quark Model, p.2](https://pdg.lbl.gov/2015/reviews/rpp2015-rev-qcd.pdf#page=2)
_Note that the resulting links lead to the correct page as well!_
1 change: 1 addition & 0 deletions src/sphinxcontrib/hep/pdgref/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _create_listing_url(entry: PDGEntry) -> str:
def _create_review_url(entry: PDGEntry) -> str:
section_url = entry.section
section_url = section_url.lower()
section_url = section_url.replace(" ", "-")
url = URLPattern.REVIEW.format(entry.year, section_url) # type: ignore
url += __create_page_anchor(entry)
return url
Expand Down
2 changes: 2 additions & 0 deletions tests/roots/test-dummy/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

:pdg-listing:`pi-plus-minus; 2018`

:pdg-review:`Quark Model; 2015; p.2`

:pdg-review:`Kinematics`

:pdg-review:`QCD; p5`
Expand Down
3 changes: 3 additions & 0 deletions tests/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_text(app, warning) -> None:
assert lines[::2] == [
f"PDG{DEFAULT_YEAR}",
"PDG2018",
"PDG2015, §Quark Model, p.2",
f"PDG{DEFAULT_YEAR}, §Kinematics",
f"PDG{DEFAULT_YEAR}, §QCD, p.5",
"PDG2014, §Resonances",
Expand All @@ -30,6 +31,7 @@ def test_html(app, warning) -> None:
assert [ref.text for ref in external_refs] == [
f"PDG{DEFAULT_YEAR}",
"PDG2018",
"PDG2015, §Quark Model, p.2",
"PDG2020, §Kinematics",
"PDG2020, §QCD, p.5",
"PDG2014, §Resonances",
Expand All @@ -38,6 +40,7 @@ def test_html(app, warning) -> None:
assert [ref.get("href") for ref in external_refs] == [
"https://pdg.lbl.gov/2020/listings/rpp2020-list-K-zero.pdf",
"https://pdg.lbl.gov/2018/listings/rpp2018-list-pi-plus-minus.pdf",
"https://pdg.lbl.gov/2015/reviews/rpp2015-rev-quark-model.pdf#page=2",
"https://pdg.lbl.gov/2020/reviews/rpp2020-rev-kinematics.pdf",
"https://pdg.lbl.gov/2020/reviews/rpp2020-rev-qcd.pdf#page=5",
"https://pdg.lbl.gov/2014/reviews/rpp2014-rev-resonances.pdf",
Expand Down

0 comments on commit 472a9be

Please sign in to comment.