Skip to content

Commit bb8896b

Browse files
fix: Avoid a Sphinx warning when a Latex package is already added (#10)
* Avoid a Sphinx warning when a Latex package is already added I use this extension and another extension which adds `ulem`. My Sphinx build gives: `WARNING: latex package 'ulem' already included`. * Add changelog entry * Update docs/changelog.rst --------- Co-authored-by: Shengyu Zhang <reg@silverrainz.me>
1 parent 5a9148c commit bb8896b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ Change Log
1919
2020
Change log here.
2121
22+
1.4
23+
---
24+
25+
.. version:: _
26+
27+
- Avoid an error which occurred when another extension has already added LaTeX packages.
28+
2229
1.3
2330
---
2431

src/sphinxnotes/strike/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ def setup(app: Sphinx):
7878
"""Sphinx extension entrypoint."""
7979
meta.pre_setup(app)
8080

81-
app.add_latex_package('ulem', 'normalem')
81+
latex_packages = ('ulem', 'normalem')
82+
for latex_package in latex_packages:
83+
# If the package is already added and we add it again, Sphinx will warn.
84+
if not app.has_latex_package(latex_package):
85+
app.add_latex_package(latex_package)
8286

8387
app.add_node(
8488
strike_node,

0 commit comments

Comments
 (0)