Skip to content

Commit 3073d4f

Browse files
authored
Add data-epub-type to ToC & Index (#1888)
* Add `data-epub-type` to ToC & Index Added to autogenerated ToC, and to index created during autogeneration by `/i...i/` markup. Fixes #1885 * Fix tests
1 parent f690177 commit 3073d4f

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/guiguts/html_convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def maybe_close_chapter_div(chapter_div_open: bool, next_step: int) -> int:
695695
maintext().replace(
696696
line_start,
697697
line_end,
698-
'<nav>\n<ul class="index">',
698+
'<nav data-epub-type="index">\n<ul class="index">',
699699
)
700700
next_step += 1
701701
reset_ibs_dict()
@@ -975,7 +975,7 @@ def maybe_close_chapter_div(chapter_div_open: bool, next_step: int) -> int:
975975
maintext().insert(
976976
contents_start,
977977
"\n<!-- Autogenerated TOC. Modify or delete as required. -->\n"
978-
f"<nav>\n<p>\n{auto_toc}</p>\n</nav>\n"
978+
f'<nav data-epub-type="toc">\n<p>\n{auto_toc}</p>\n</nav>\n'
979979
"<!-- End Autogenerated TOC. -->\n\n",
980980
)
981981

tests/expected/htmlconvert1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ img.w100 {width: 100%;}
255255

256256

257257
<!-- Autogenerated TOC. Modify or delete as required. -->
258-
<nav>
258+
<nav data-epub-type="toc">
259259
<p>
260260
<a href="#NOTES_FROM_CALAIS_BASE">NOTES FROM CALAIS BASE ——-File: 002.png————————————————————————————- [Blank Page] ——-File: px003a.png———————————————————————————- /s p003a</a><br>
261261
<a href="#TRAINING_IN_FRANCE">TRAINING IN FRANCE</a><br>

tests/expected/htmlconvert2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ CHERRY-BLOSSOMS
335335
</div>
336336

337337
<!-- Autogenerated TOC. Modify or delete as required. -->
338-
<nav>
338+
<nav data-epub-type="toc">
339339
<p>
340340
<a href="#Many_have_been_before_me_and_the_theme">Many have been before me, and the theme of this volume can hardly be called new, for Japan has been viewed from every side and through all kinds of eyes. This, however, has not deterred me from jotting down a few observations and experiences of my own, hoping that in them my readers may feel some rays of the Orient sunshine and beauty. I desire to thank Mr. Burton J. Hendrick for the kind and sympathetic aid given upon the manuscript.</a><br>
341341
<a href="#CONTENTS">CONTENTS.</a><br>

0 commit comments

Comments
 (0)