Overview

I had the opportunity to convert TEI/XML files to EPUB using Python, so here are my notes.

While Oxygen XML Editor is one method for converting TEI/XML files to EPUB, this time I used the Python library “EbookLib.” I referenced the following article.

https://dev.classmethod.jp/articles/try-create-epub-by-python-ebooklib/

In particular, this time the goal is to create a vertical-text EPUB from the TEI/XML files published in the “Koui Genji Monogatari Text Data Repository.”

Conversion Method

The source code is available in the following notebook.

https://colab.research.google.com/github/nakamura196/ndl_ocr/blob/main/Pythonを用いてTEI_XMLファイルをEPUBに変換する.ipynb

Results

As shown below, you can view the Koui Genji Monogatari text in an EPUB-compatible reader.

By modifying the HTML and CSS, I believe various display styles can be achieved.

I hope this serves as a useful reference for utilizing TEI/XML.