[Resurrection!] Suggested forum feature: ruby text

This was discussed previously, but on the old forums.

Not sure how you’re hosting Discourse, but it might be much easier to integrate an extension to handle <ruby> tag wrapping now. Considering how much discussion is already here (and should continue into the future :D) it would be nice to have a better way to format character readings - rather than always writing something along the lines of 悔(くや)しい.

Here’s a few that I found for transforming markdown:
PHP: https://github.com/noisan/parsedown-rubytext
Python: https://github.com/djfun/furigana_markdown
Node: https://www.npmjs.com/package/showdown-kanji

If it’s not feasible with your setup, all good.
Thought I’d mention them in case it’s an easy win now that the forums have changed.

NB: Whether or not furigana is beneficial is tangential to having a standard way to display them. People do write readings on the forums, especially when discussing the language / answering questions.

9 Likes

Should I tag @viet?

I do think it would be useful, I personally hate how it looks when you have to put kana in parentheses all over the place.

Can’t say no now!

I hate to suggest more work for them though :blush:

The parsedown format is quite nice.
[素晴]^(すば)らしい

becomes

7 Likes

@Viet our holy programming guru, may we please have ruby text.

SOMEONE BRING OUT THE SACRIFICE.

2 Likes

A +1 from me. 'Twould be handy.

I’m sure if one of our resident Ruby programmers wanted to write a Discourse extension, Viet would consider in installing it :slight_smile:

2 Likes

What about a format like Stack Exchange uses:

[素晴]^(すば)らしい

would instead be

[素晴]{すば}らしい

It might be easier to type.

2 Likes

I made a Discourse plugin for this. Still needs some work and testing, but it basically works.

6 Likes

:100: internet points to you sir!

I agree about using the StackExchange format! I do want to point out that they also allow furigana with the following syntax:

素晴【すば】らしい

That’s a syntax I really like - it’s natural; no weird markup. How about adding that one too, @xv435? :grin:

Also… what’s up with the “strip_email” thing? What’s e-mail got to do with anything? :thinking:

I also like the syntax with the single set of 【】, but it is going to require some extra code to determine which text to place the furigana over. I should be able to add it though.

Some email providers don’t support ruby tags (I tried it in gmail, and it deleted everything inside the ruby tag: the text and furigana). Discourse occasionally sends email updates that might contain markdown from posts, that code strips all the ruby tags so the furigana will appear in parentheses.

2 Likes

Ah, sweet! Perhaps the furigana should appear in 【】 in e-mails, then? Seeing as they’re usually used to indicate furigana where it’s not supported.

I’ve noticed a few oddities about Stack Exchange’s furigana support, by the way. Given the following markdown:

Differences:

* [漢字]{かんじ} [カナ]{カナ} [漢字]{kanji} [kanji]{かんじ} [kanji]{kanji}
* 漢字{かんじ} カナ{カナ} 漢字{kanji} kanji{かんじ} kanji{kanji}
* 漢字【かんじ】 カナ【カナ】 漢字【kanji】 kanji【かんじ】 kanji【kanji】

The following image is the result:

Some of these idiosyncracies might be sensible. Putting furigana over romaji without explicitly specifying which part? I’m not sure that’s a good idea, seeing as… you know… spaces. However, I don’t see any reason to disallow putting romaji above kanji, or putting things over kana only.

Another gripe I have is that escaping these sequences doesn’t work at all on StackExchange. Check this odd pair out:

[Link]\(http://example.com/)  
[漢字]\{かんじ}  
漢字\{かんじ}  
漢字\【かんじ】

That’s just plain broken! Wiiildly inconsistent. So… if you could implement sensible behavior for those, that’d be sweet and you could honestly say you’re better than Stack Exchange. :smile:

I allowed escaping the sequences and set 【】as the default for emails/incompatible browsers.

I agree the oddities in the furigana support, I don’t see any reason to disallow anything in the furigana itself since the furigana is always in brackets.

The reason that putting things over kana only is disallowed is that kana are used to determine where to place the furigana.

For example,

私は行【い】く。

The い in 行く could apply to anything before it. However, the は serves as a marker to help place the furigana. Ramaji, punctuation, and other special characters (anything that is not kanji) also serve as markers.

So I will allow the automatically placed furigana to have anything in the furigana, but only kanji in the text. In the example you gave above (漢字【かんじ】 カナ【カナ】) it might be possible, but adding support for anything but kanji in the automatic placement would lead to inconsistent behavior in many cases.

4 Likes

Ah, I see! That makes a whole bunch of sense. Great observation.

I’m really hoping for official installation now! If you send off an e-mail to hello@wanikani.com, they might just do it. Viet and the gang are usually very responsive.

Great work! Thanks for taking ownership of this :smile:

Here’s an example post I made in Discourse to demonstrate the features so far:

You may notice the 小夜時雨 kanji are in the wrong order in the picture; that issue is fixed.

Are there any other features anyone can think of that would be good to add?

6 Likes

Sorry for the late response.

We are hosted on discourse.org and unfortunately our plan does not offer a plug-in option. Therefore we can’t extend support (whitelist basically) ruby tags.

I would try asking over at meta.discourse.org to see if ruby tags can be whitelisted by default.

2 Likes