diff --git a/jupyter_book_to_htmlbook/file_processing.py b/jupyter_book_to_htmlbook/file_processing.py index c755db0..9ff1c4e 100644 --- a/jupyter_book_to_htmlbook/file_processing.py +++ b/jupyter_book_to_htmlbook/file_processing.py @@ -232,7 +232,7 @@ def process_chapter_soup( else: chapter['xmlns'] = 'http://www.w3.org/1999/xhtml' # type: ignore - del chapter['class'] + del chapter['class'] # type: ignore # promote subheadings within "base" chapter chapter = promote_headings(chapter) @@ -242,10 +242,12 @@ def process_chapter_soup( subsections, sub_bib = process_chapter_subparts(subfile) if subsections: for subsection in subsections: - chapter.append(subsection) + chapter.append(subsection) # type: ignore if bib and sub_bib: entries = sub_bib.find_all("dd") # type: ignore bib.dl.extend(entries) # type: ignore + # throw away the sub-bib section + _ = sub_bib.extract() elif sub_bib: bib = sub_bib @@ -328,7 +330,7 @@ def process_chapter(toc_element, chapter, ids = process_ids(chapter, book_ids) # write the file, preserving any directory structure(s) from source - if type(toc_element) == list: + if type(toc_element) is list: dir_structure = [p for p in toc_element[0].parts if p not in source_dir.parts] else: diff --git a/poetry.lock b/poetry.lock index 6e1d1f4..a11dc9b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2581,6 +2581,18 @@ pure-eval = "*" [package.extras] tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"] +[[package]] +name = "standard-imghdr" +version = "3.13.0" +description = "Standard library imghdr redistribution. \"dead battery\"." +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "standard_imghdr-3.13.0-py3-none-any.whl", hash = "sha256:30a1bff5465605bb496f842a6ac3cc1f2131bf3025b0da28d4877d6d4b7cc8e9"}, + {file = "standard_imghdr-3.13.0.tar.gz", hash = "sha256:8d9c68058d882f6fc3542a8d39ef9ff94d2187dc90bd0c851e0902776b7b7a42"}, +] + [[package]] name = "tabulate" version = "0.9.0" @@ -2698,6 +2710,33 @@ dev = ["autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "pre-commit (>=2 doc = ["cairosvg (>=2.5.2,<3.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pillow (>=9.3.0,<10.0.0)"] test = ["black (>=22.3.0,<23.0.0)", "coverage (>=6.2,<7.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.910)", "pytest (>=4.4.0,<8.0.0)", "pytest-cov (>=2.10.0,<5.0.0)", "pytest-sugar (>=0.9.4,<0.10.0)", "pytest-xdist (>=1.32.0,<4.0.0)", "rich (>=10.11.0,<13.0.0)", "shellingham (>=1.3.0,<2.0.0)"] +[[package]] +name = "types-beautifulsoup4" +version = "4.12.0.20250516" +description = "Typing stubs for beautifulsoup4" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "types_beautifulsoup4-4.12.0.20250516-py3-none-any.whl", hash = "sha256:5923399d4a1ba9cc8f0096fe334cc732e130269541d66261bb42ab039c0376ee"}, + {file = "types_beautifulsoup4-4.12.0.20250516.tar.gz", hash = "sha256:aa19dd73b33b70d6296adf92da8ab8a0c945c507e6fb7d5db553415cc77b417e"}, +] + +[package.dependencies] +types-html5lib = "*" + +[[package]] +name = "types-html5lib" +version = "1.1.11.20250917" +description = "Typing stubs for html5lib" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "types_html5lib-1.1.11.20250917-py3-none-any.whl", hash = "sha256:b294fd06d60da205daeb2f615485ca4d475088d2eff1009cf427f4a80fcd5346"}, + {file = "types_html5lib-1.1.11.20250917.tar.gz", hash = "sha256:7b52743377f33f9b4fd7385afbd2d457b8864ee51f90ff2a795ad9e8c053373a"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -2793,4 +2832,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "252da0cae6f5fb6faecec0aa4f64adca50835709419bb988dd723c5b50d0250e" +content-hash = "f3fee1a035bfc50965fe6a5fdeab8c17e871e7be0e4ad752c7e5ab9a409656bd" diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..ab1033b --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true diff --git a/pyproject.toml b/pyproject.toml index 5a322d9..12d91c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ PyYAML = "^6.0" jupyter-book = "^0.15.1" docutils = "0.17.1" lxml = "^6.0.1" +standard-imghdr = "^3.13.0" [tool.poetry.scripts] jb2htmlbook = "jupyter_book_to_htmlbook.main:main" @@ -20,6 +21,7 @@ jb2atlas = "jupyter_book_to_htmlbook.main:main" [tool.poetry.group.dev.dependencies] pytest = "^8.4.2" pytest-cov = "^7.0.0" +types-beautifulsoup4 = "^4.12.0.20250516" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/example_book/_build/html/bibliography.html b/tests/example_book/_build/html/bibliography.html index ca6f1c4..7d83f02 100644 --- a/tests/example_book/_build/html/bibliography.html +++ b/tests/example_book/_build/html/bibliography.html @@ -3,7 +3,7 @@ - + @@ -15,19 +15,19 @@ - - - + + + - - - - + + + + @@ -38,8 +38,9 @@ - - + + + @@ -74,19 +75,23 @@ - + + +
+ + + - + id="pst-primary-sidebar-checkbox"/> + - + id="pst-secondary-sidebar-checkbox"/> +
@@ -108,13 +113,21 @@ Ctrl+K
+ +
+ +
+ - + +
+ +
@@ -128,6 +141,9 @@ -
+
@@ -199,7 +211,7 @@
-
+
@@ -281,20 +293,22 @@ + + @@ -321,7 +335,7 @@

Bibliography

-
-
@@ -407,6 +417,7 @@

Bibliography +

Bibliography - + +
diff --git a/tests/example_book/_build/html/genindex.html b/tests/example_book/_build/html/genindex.html index 912d883..9a5465c 100644 --- a/tests/example_book/_build/html/genindex.html +++ b/tests/example_book/_build/html/genindex.html @@ -3,7 +3,7 @@ - + @@ -14,19 +14,19 @@ - - - + + + - - - - + + + + @@ -37,8 +37,9 @@ - - + + + @@ -72,19 +73,23 @@ -
+ + +
+ + + - + id="pst-primary-sidebar-checkbox"/> + - + id="pst-secondary-sidebar-checkbox"/> +
@@ -106,13 +111,23 @@ Ctrl+K

+ +
+ +
+ - + +
+ + + +
@@ -126,6 +141,9 @@ -
+
@@ -192,7 +211,7 @@
-
+
@@ -226,20 +245,22 @@ + + @@ -266,7 +287,7 @@

-
+

Index

@@ -303,16 +324,12 @@

G

-
+ + +
-
- -
-
-
-
@@ -335,6 +352,7 @@

G

- - + +
diff --git a/tests/example_book/_build/html/intro.html b/tests/example_book/_build/html/intro.html index 9804a8f..0a8fcb0 100644 --- a/tests/example_book/_build/html/intro.html +++ b/tests/example_book/_build/html/intro.html @@ -3,7 +3,7 @@ - + @@ -15,19 +15,19 @@ - - - + + + - - - - + + + + @@ -38,8 +38,9 @@ - - + + + @@ -74,19 +75,23 @@ - + + +
+ + + - + id="pst-primary-sidebar-checkbox"/> + - + id="pst-secondary-sidebar-checkbox"/> +
@@ -108,13 +113,23 @@ Ctrl+K
+ +
+ +
+ - + +
+ + + +
@@ -128,6 +143,9 @@ -
+
@@ -194,7 +213,7 @@
-
+
@@ -276,20 +295,22 @@ + + @@ -316,7 +337,7 @@

An Example Jupyter Book

-
@@ -421,6 +438,7 @@

An Example Jupyter Book +

An Example Jupyter Book - - + +
diff --git a/tests/example_book/_build/html/notebooks/ch01.html b/tests/example_book/_build/html/notebooks/ch01.html index 85c568c..8a64ffa 100644 --- a/tests/example_book/_build/html/notebooks/ch01.html +++ b/tests/example_book/_build/html/notebooks/ch01.html @@ -3,7 +3,7 @@ - + @@ -15,19 +15,19 @@ - - - + + + - - - - + + + + @@ -38,8 +38,9 @@ - - + + + @@ -75,19 +76,23 @@ -
+ + +
+ + + - + id="pst-primary-sidebar-checkbox"/> + - + id="pst-secondary-sidebar-checkbox"/> +
@@ -109,13 +114,21 @@ Ctrl+K

+ +
+ +
+ - + +
+ +
@@ -129,6 +142,9 @@ -
+
@@ -200,7 +212,7 @@
-
+
@@ -282,20 +294,22 @@ + + @@ -322,7 +336,7 @@

Jupyter Notebooks and Atlas

-
+

Jupyter Notebooks and Atlas#

@@ -335,7 +349,7 @@

Jupyter Notebooks and Atlas

Also, why not some executable code? See the following:

-
def hello(name: str):
+
def hello(name: str):
     print(f"Hello, {name}")
 
 hello("Jane")
@@ -430,11 +444,10 @@ 

Jupyter Notebooks and Atlas

-
-
@@ -480,6 +490,7 @@

Jupyter Notebooks and Atlas

- - + +
diff --git a/tests/example_book/_build/html/notebooks/ch02.00.html b/tests/example_book/_build/html/notebooks/ch02.00.html index aaa95fc..d86fbca 100644 --- a/tests/example_book/_build/html/notebooks/ch02.00.html +++ b/tests/example_book/_build/html/notebooks/ch02.00.html @@ -3,7 +3,7 @@ - + @@ -15,19 +15,19 @@ - - - + + + - - - - + + + + @@ -38,8 +38,9 @@ - - + + + @@ -75,19 +76,23 @@ - + + +
+ + + - + id="pst-primary-sidebar-checkbox"/> + - + id="pst-secondary-sidebar-checkbox"/> +
@@ -109,13 +114,21 @@ Ctrl+K
+ +
+ +
+ - + +
+ +
@@ -129,6 +142,9 @@ -
+
@@ -200,7 +212,7 @@
-
+
@@ -282,20 +294,22 @@ + + @@ -334,7 +348,7 @@

Contents

-
@@ -445,6 +455,7 @@

Bibliography