obynio/anki-japanese-furigana

Add spaces after readings for bracket notation to delimit words in sentences

qntoine opened this issue · 6 comments

As highlighted by another user on https://ankiweb.net/shared/info/678316993, spaces are not added between words (after the generated reading and before the next character), so that furigana are not rendered correctly in some situations unless fixed manually.

ahlec commented

Is this for the Ruby/HTML markup, or the bracket notation? The former is generating them correctly.

Indeed, that would be for the bracket notation — which I and other users may prefer for legacy & compatibility reasons.
It is also easier for copy-pasting or when needing to manually fix reading mistakes, which happens more often than not.

Merci :)

ahlec commented

Awesome, that helps narrow it down. When you say it's not "rendered correctly" in some situations: is there some other tool/plugin that you're using as well that's converting the bracket notation into some other format? Would you be able to provide a screenshot of a sentence that doesn't render correctly, so we have a test case to work with while we're coding the fix?

Sure, here is a screenshot of what I get after pasting a random sentence into Anki and running the plugin without any other modification or conversion:
image
For reference, the base text (unedited) with automatically generated furigana is as follows: 宅[たく]建[けん]業[ぎょう](宅地[たくち]建物[たてもの]取引[とりひき]業[ぎょう])とは、「宅地[たくち]・建物[たてもの]」の「取引[とりひき]」を「業[ぎょう]」として行[おこな]うことをいいます。宅[たく]建[けん]菜[さい]を営[いとな]むためには、免許[めんきょ](後[ご]込[こみ])を受[う]けなければなりません。

The fix is probably to just add a space at this line: https://github.com/obynio/anki-japanese-furigana/blob/master/reading.py#L153

Before:

return '%s[%s]' % (self.text, self.reading)

After:

return ' %s[%s]' % (self.text, self.reading)

Changed it on my copy and observed that the plugin now does the annotation correctly.

obynio commented

This issue was fixed and released in 1.4.6 🫡
Feel free to comment the pull request above in case of issues