I found a book that I can't convert with this plugin.
Exception content:
Code:
Exception: rb element not a child of ruby element: b'<ruby><span><rb-bad>珠</rb-bad><img src="image_rsrcCED.jpg" alt="" style="-kfx-render: inline; -kfx-style-name: s5FU; box-sizing: content-box; height: 1em; max-height: 100%; vertical-align: baseline; width: 1em"/></span></ruby>'
I analyzed this problem by myself and concluded this check is not required (at least in my case).
This book uses the image for non-standard characters, so
Code:
<ruby><rb>珠</rb><rt>ruby1</rt><rb><img ... /></rb><rt>ruby2</rt></ruby>
is desired.
I slightly modified the code to the below and confirmed it works in my case:
Code:
while rb_elem.getparent() is not event_elem:
if len(rb_elem.getparent()) != 1:
# rb_elem.tag = "rb-bad"
# raise Exception("rb element not a child of ruby element: %s" % etree.tostring(event_elem))
break # CHANGED to break
rb_elem = rb_elem.getparent()
rb_elem = self.replace_element_with_container(rb_elem, "rb")
rb_parent = rb_elem.getparent() # ADD
ruby_id = ruby_id_entry.pop("$758")
ruby_content = self.get_ruby_content(ruby_name, ruby_id)
if ruby_content.pop("$159") == "$269":
rt_elem = etree.Element("rt")
rb_parent.insert(rb_parent.index(rb_elem) + 1, rt_elem) # MODIFIED to rb_parent