Skip to content

Commit 44acbf3

Browse files
authored
Merge pull request #79 from oreillymedia/try-3-13-again
Try 3 13 again
2 parents ca7f24a + cef1021 commit 44acbf3

30 files changed

+1296
-708
lines changed

jupyter_book_to_htmlbook/file_processing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def process_chapter_soup(
232232

233233
else:
234234
chapter['xmlns'] = 'http://www.w3.org/1999/xhtml' # type: ignore
235-
del chapter['class']
235+
del chapter['class'] # type: ignore
236236

237237
# promote subheadings within "base" chapter
238238
chapter = promote_headings(chapter)
@@ -242,10 +242,12 @@ def process_chapter_soup(
242242
subsections, sub_bib = process_chapter_subparts(subfile)
243243
if subsections:
244244
for subsection in subsections:
245-
chapter.append(subsection)
245+
chapter.append(subsection) # type: ignore
246246
if bib and sub_bib:
247247
entries = sub_bib.find_all("dd") # type: ignore
248248
bib.dl.extend(entries) # type: ignore
249+
# throw away the sub-bib section
250+
_ = sub_bib.extract()
249251
elif sub_bib:
250252
bib = sub_bib
251253

@@ -328,7 +330,7 @@ def process_chapter(toc_element,
328330
chapter, ids = process_ids(chapter, book_ids)
329331

330332
# write the file, preserving any directory structure(s) from source
331-
if type(toc_element) == list:
333+
if type(toc_element) is list:
332334
dir_structure = [p for p in toc_element[0].parts
333335
if p not in source_dir.parts]
334336
else:

poetry.lock

Lines changed: 40 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
in-project = true

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PyYAML = "^6.0"
1212
jupyter-book = "^0.15.1"
1313
docutils = "0.17.1"
1414
lxml = "^6.0.1"
15+
standard-imghdr = "^3.13.0"
1516

1617
[tool.poetry.scripts]
1718
jb2htmlbook = "jupyter_book_to_htmlbook.main:main"
@@ -20,6 +21,7 @@ jb2atlas = "jupyter_book_to_htmlbook.main:main"
2021
[tool.poetry.group.dev.dependencies]
2122
pytest = "^8.4.2"
2223
pytest-cov = "^7.0.0"
24+
types-beautifulsoup4 = "^4.12.0.20250516"
2325

2426
[build-system]
2527
requires = ["poetry-core>=1.0.0"]

tests/example_book/_build/html/bibliography.html

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!DOCTYPE html>
44

55

6-
<html lang="en" >
6+
<html lang="en" data-content_root="" >
77

88
<head>
99
<meta charset="utf-8" />
@@ -15,19 +15,19 @@
1515

1616
<script data-cfasync="false">
1717
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
18-
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
18+
document.documentElement.dataset.theme = localStorage.getItem("theme") || "";
1919
</script>
2020

2121
<!-- Loaded before other Sphinx assets -->
22-
<link href="_static/styles/theme.css?digest=e353d410970836974a52" rel="stylesheet" />
23-
<link href="_static/styles/bootstrap.css?digest=e353d410970836974a52" rel="stylesheet" />
24-
<link href="_static/styles/pydata-sphinx-theme.css?digest=e353d410970836974a52" rel="stylesheet" />
22+
<link href="_static/styles/theme.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
23+
<link href="_static/styles/bootstrap.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
24+
<link href="_static/styles/pydata-sphinx-theme.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
2525

2626

27-
<link href="_static/vendor/fontawesome/6.1.2/css/all.min.css?digest=e353d410970836974a52" rel="stylesheet" />
28-
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-solid-900.woff2" />
29-
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-brands-400.woff2" />
30-
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-regular-400.woff2" />
27+
<link href="_static/vendor/fontawesome/6.5.2/css/all.min.css?digest=dfe6caa3a7d634c4db9b" rel="stylesheet" />
28+
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.5.2/webfonts/fa-solid-900.woff2" />
29+
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.5.2/webfonts/fa-brands-400.woff2" />
30+
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.5.2/webfonts/fa-regular-400.woff2" />
3131

3232
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
3333
<link rel="stylesheet" href="_static/styles/sphinx-book-theme.css?digest=14f4ca6b54d191a8c7657f6c759bf11a5fb86285" type="text/css" />
@@ -38,8 +38,9 @@
3838
<link rel="stylesheet" type="text/css" href="_static/design-style.4045f2051d55cab465a707391d5b2007.min.css" />
3939

4040
<!-- Pre-loaded scripts that we'll load fully later -->
41-
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=e353d410970836974a52" />
42-
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=e353d410970836974a52" />
41+
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b" />
42+
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=dfe6caa3a7d634c4db9b" />
43+
<script src="_static/vendor/fontawesome/6.5.2/js/all.min.js?digest=dfe6caa3a7d634c4db9b"></script>
4344

4445
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
4546
<script src="_static/jquery.js"></script>
@@ -74,19 +75,23 @@
7475

7576

7677

77-
<a class="skip-link" href="#main-content">Skip to main content</a>
78+
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
79+
80+
<div id="pst-scroll-pixel-helper"></div>
81+
82+
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
83+
<i class="fa-solid fa-arrow-up"></i>Back to top</button>
84+
7885

7986
<input type="checkbox"
8087
class="sidebar-toggle"
81-
name="__primary"
82-
id="__primary"/>
83-
<label class="overlay overlay-primary" for="__primary"></label>
88+
id="pst-primary-sidebar-checkbox"/>
89+
<label class="overlay overlay-primary" for="pst-primary-sidebar-checkbox"></label>
8490

8591
<input type="checkbox"
8692
class="sidebar-toggle"
87-
name="__secondary"
88-
id="__secondary"/>
89-
<label class="overlay overlay-secondary" for="__secondary"></label>
93+
id="pst-secondary-sidebar-checkbox"/>
94+
<label class="overlay overlay-secondary" for="pst-secondary-sidebar-checkbox"></label>
9095

9196
<div class="search-button__wrapper">
9297
<div class="search-button__overlay"></div>
@@ -108,13 +113,21 @@
108113
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
109114
</form></div>
110115
</div>
116+
117+
<div class="pst-async-banner-revealer d-none">
118+
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
119+
</div>
120+
111121

112-
<nav class="bd-header navbar navbar-expand-lg bd-navbar">
113-
</nav>
122+
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
123+
</header>
114124

125+
115126
<div class="bd-container">
116127
<div class="bd-container__inner bd-page-width">
117128

129+
130+
118131
<div class="bd-sidebar-primary bd-sidebar">
119132

120133

@@ -128,6 +141,9 @@
128141

129142
<div class="sidebar-primary-items__start sidebar-primary__section">
130143
<div class="sidebar-primary-item">
144+
145+
146+
131147

132148

133149
<a class="navbar-brand logo" href="intro.html">
@@ -136,6 +152,7 @@
136152

137153

138154

155+
139156
<p class="title logo__title">Hello World with Jupyter Book</p>
140157

141158
</a></div>
@@ -163,11 +180,6 @@
163180
<ul class="nav bd-sidenav">
164181
<li class="toctree-l1"><a class="reference internal" href="notebooks/code_py.html">Code</a></li>
165182
<li class="toctree-l1"><a class="reference internal" href="notebooks/code_r.html">This Is a Title</a></li>
166-
</ul>
167-
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Edge Cases</span></p>
168-
<ul class="nav bd-sidenav">
169-
<li class="toctree-l1"><a class="reference internal" href="notebooks/many_a_levels.html">My Main Title</a></li>
170-
171183
</ul>
172184
<p aria-level="2" class="caption" role="heading"><span class="caption-text">References</span></p>
173185
<ul class="current nav bd-sidenav">
@@ -190,7 +202,7 @@
190202

191203
</div>
192204

193-
<main id="main-content" class="bd-main">
205+
<main id="main-content" class="bd-main" role="main">
194206

195207

196208

@@ -199,7 +211,7 @@
199211
<div class="bd-content">
200212
<div class="bd-article-container">
201213

202-
<div class="bd-header-article">
214+
<div class="bd-header-article d-print-none">
203215
<div class="header-article-items header-article__inner">
204216

205217
<div class="header-article-items__start">
@@ -281,20 +293,22 @@
281293
</button>
282294

283295

296+
284297
<script>
285298
document.write(`
286-
<button class="theme-switch-button btn btn-sm btn-outline-primary navbar-btn rounded-circle" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
287-
<span class="theme-switch" data-mode="light"><i class="fa-solid fa-sun"></i></span>
288-
<span class="theme-switch" data-mode="dark"><i class="fa-solid fa-moon"></i></span>
289-
<span class="theme-switch" data-mode="auto"><i class="fa-solid fa-circle-half-stroke"></i></span>
299+
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
300+
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light"></i>
301+
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark"></i>
302+
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto"></i>
290303
</button>
291304
`);
292305
</script>
293306

307+
294308
<script>
295309
document.write(`
296-
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
297-
<i class="fa-solid fa-magnifying-glass"></i>
310+
<button class="btn btn-sm pst-navbar-icon search-button search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
311+
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
298312
</button>
299313
`);
300314
</script>
@@ -321,7 +335,7 @@ <h1>Bibliography</h1>
321335

322336

323337
<div id="searchbox"></div>
324-
<article class="bd-article" role="main">
338+
<article class="bd-article">
325339

326340
<section id="bibliography">
327341
<h1>Bibliography<a class="headerlink" href="#bibliography" title="Permalink to this heading">#</a></h1>
@@ -366,11 +380,10 @@ <h1>Bibliography<a class="headerlink" href="#bibliography" title="Permalink to t
366380

367381

368382

369-
<footer class="bd-footer-article">
383+
384+
385+
<footer class="prev-next-footer d-print-none">
370386

371-
<div class="footer-article-items footer-article__inner">
372-
373-
<div class="footer-article-item"><!-- Previous / next buttons -->
374387
<div class="prev-next-area">
375388
<a class="left-prev"
376389
href="notebooks/glossary.html"
@@ -381,10 +394,7 @@ <h1>Bibliography<a class="headerlink" href="#bibliography" title="Permalink to t
381394
<p class="prev-next-title">Glossary</p>
382395
</div>
383396
</a>
384-
</div></div>
385-
386397
</div>
387-
388398
</footer>
389399

390400
</div>
@@ -407,6 +417,7 @@ <h1>Bibliography<a class="headerlink" href="#bibliography" title="Permalink to t
407417

408418
<div class="footer-item">
409419

420+
410421
<p class="copyright">
411422

412423
© Copyright 2022.
@@ -433,8 +444,8 @@ <h1>Bibliography<a class="headerlink" href="#bibliography" title="Permalink to t
433444
</div>
434445

435446
<!-- Scripts loaded after <body> so the DOM is not blocked -->
436-
<script src="_static/scripts/bootstrap.js?digest=e353d410970836974a52"></script>
437-
<script src="_static/scripts/pydata-sphinx-theme.js?digest=e353d410970836974a52"></script>
447+
<script src="_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b"></script>
448+
<script src="_static/scripts/pydata-sphinx-theme.js?digest=dfe6caa3a7d634c4db9b"></script>
438449

439450
<footer class="bd-footer">
440451
</footer>

0 commit comments

Comments
 (0)