obynio / anki-japanese-furigana

Anki add-on providing support for adding furigana on Japanese text
https://ankiweb.net/shared/info/678316993
GNU General Public License v3.0
17 stars 5 forks source link

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

Closed qntoine closed 4 months ago

qntoine commented 1 year ago

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 1 year ago

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

qntoine commented 1 year ago

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 1 year ago

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?

qntoine commented 1 year ago

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: 宅[たく]建[けん]業[ぎょう](宅地[たくち]建物[たてもの]取引[とりひき]業[ぎょう])とは、「宅地[たくち]・建物[たてもの]」の「取引[とりひき]」を「業[ぎょう]」として行[おこな]うことをいいます。宅[たく]建[けん]菜[さい]を営[いとな]むためには、免許[めんきょ](後[ご]込[こみ])を受[う]けなければなりません。

vbomedeiros commented 1 year ago

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 4 months ago

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