It’s in the code too
And it gets nicer (what it looks like for me on that post)
Is this already a bug report?
No, I think it’s fine
Here, I left a space so it didn’t become like this
Version 1.1 patch-notes:
Upgraded from Discord to Discourse
Fixed the typo/mistake where I wrote “Discord” instead of “Discourse”.
If I broke something in this patch I’d be very surprised.
Link to previous script version for downgrading in case you want to live the Discord life
I’ve been meaning to make my own markdown script, but hacking it into the post cooking is a pain. I have a working markdown plugin, which would be more useful across the board. But WaniKani’s Discourse plan doesn’t currently support custom plugins. So I’m trying to convert that plugin into a standalone script for the time being, but running it through the markdown engine without converting markdown unrelated to ruby is a pain.
w.require("pretty-text/engines/discourse-markdown-it").cook actually work? I wouldn’t think it would. I think if I run the whole post through that I’d still end up converting unrelated markdown, so I need to find a way to only convert highlighted text or something like that.
Yes, as soon as someone inputs something like:
I also had to inject into the
save() function – probably because
Discord Discourse doesn’t accept a cooked string if it doesn’t match the raw input? Therefore I convert the furigana markup in the raw input right before
save() is called.
Version 1.2 patch-notes:
Ruby to furigana markup feature
As soon as ruby markup is detected in the input box, IME2Furigana now offers to convert it into the more compact furigana markup form.
If I broke something please let me know.
Link to previous script version for downgrading in case version 1.2 doesn’t work
Does this really need a prompt?
I’m not sure – there might be cases where my ruby markup parser fails (it definitely fails with nested ruby tags). The resulting markup (after conversion to furigana markup and then back to ruby) is also most likely not the same anymore, so for example the Discourse functionality where it highlights the quoted part of the whole post after expanding the quotation would probably not work (I haven’t verified this). And since I automatically add lang=“ja-JP” to the ruby tag, the visual appearance of quoted parts might also be altered. Therefore I wanted to leave the user the choice before manipulating what they wrote.
Would you prefer a different behavior?
That all makes sense. I would like it to just convert it, but I understand that it might not be for everyone. Could you maybe make it a setting at least? Maybe just a variable at the top of the script?
Okay, no problem
By the way, thank you for suggesting my script for the Japanese Only (Beginners) threads! Do you know if Mami-sensei also uses userscripts for her posts? Since she uses
<del> tags inside ruby, this might lead to problems with my script. For example
<振>[ふ]り<仮<del>仮</del>名>[がな] leads to 振り<仮
I guess finding a fix for this will be the next point on my to-do list.
I don’t know, buy my impression is that she doesn’t
With your script, what is actually saved for the post? The ruby tags or the markdown?
Version 1.3 patch-notes:
Added setting for unprompted ruby to furigana markup conversion
You have to edit the script and set
Sorry for not providing a more convenient way to access settings. I’m wondering if it would be a good idea to add a settings section for my script in the Discourse preferences menu?
The ruby tags. For some reason the result after posting was always <漢字>[かんじ], instead of 漢字. Either I missed some place where I would have had to inject something, or the server does some sanity checks?
I’m pretty sure the “cook” functionality for the markdown is run on the server. I think the client-side copy only runs for the preview pane.
Yes, so I assume there is no other option than to save as ruby tags.
Version 1.4 patch-notes:
Until now, every text that did not contain kanji was classified as “user input” that should potentially be used as furigana. That could lead to problems if the IME first converts the input into katakana or even emoji and afterwards into kanji. The last “input” not containing kanji was then used as furigana, leading to 狼 or 汗.
Now it uses the last input containing only hiragana or punctuation marks. I hope nobody plans to use their IME in katakana mode and wants their katakana input as furigana.
Tags in furigana markup
It should now be possible to use tags like
<del> inside of furigana markup. Examples:
That’s probably a feature nobody will ever use.
Please let me know if something doesn’t work.
Link to previous script version for downgrading in case version 1.4 doesn’t work for you