This is a memo on how to achieve double-sided ruby (furigana) in Word using python-docx.

You can try it from the following notebook.

https://colab.research.google.com/github/nakamura196/ndl_ocr/blob/main/python_docxを用いた両側ルビ.ipynb

An output example is shown below.

An input example is shown below.

<body>
<p>
 私は
 <ruby>
  <rb>
   <ruby>
    <rb></rb>
    <rt place="right"></rt>
   </ruby>
   <ruby>
    <rb></rb>
    <rt place="right">キウ</rt>
   </ruby>
  </rb>
  <rt place="left">ビリヤード</rt>
 </ruby>
 に行きました。
</p>
<p>
 <ruby>
  <rb>入学試験</rb>
  <rt place="above">にゅうがくしけん</rt>
 </ruby>
 があります。
</p>
</body>

The program is still incomplete, but I hope it serves as a helpful reference.