You could use it for pinyin annotations too, or really any combination of scripts.
睾丸 に豚の糞
猪蛋蛋上的粪便
фекалии на свиных яйцах
People were just talking about this in a thread earlier but I can’t find it anymore. Figured this would be a good place for it.
Check out the source code of this post. It actually looks for space characters after the pipe symbol and uses that to group the furigana. It’s actually easiest to use for Chinese, Japanese is a bit more work, and alphabetical scripts are pretty time consuming, because you have to mark up each word with brackets and pipes, spaces don’t cut it.
Ooh, I knew about the basic syntax but I didn’t know about the spaces thing! Should definitely same some time and hassle. Also makes copy-pasting the text much nicer, since the ruby text goes after each bracket grouping which is pretty terrible if you’ve marked up each individual character.
The one potential downside is that this approach doesn’t add additional space between each group if the ruby text is long and spills over to neighboring groups. Compare these two results, where the top uses the spaces approach and the bottom individually marks each word/particle:
猪蛋蛋上的粪便
猪蛋蛋上的粪便
You can see that some extra space is left around 上 so that shàng can remain centered over it. However, there’s a separate downside to this: it appears that while it will prevent ruby text from outright overlapping, it doesn’t actually try to insert any space between adjacent groupings. So if I use the same pinyin style as your original post, the result around dàn dàn is not great:
猪蛋蛋上的粪便
You can combat this by adding trailing spaces as needed, but it will look a bit haphazard because the space is included in the width when centering the ruby text, making everything look shifted to the left (here I put spaces after Zhū and dàn dàn):
猪蛋蛋上的粪便
Unless the text is so long that it becomes difficult to understand which reading goes with which character(s), it’s more of an aesthetic choice than anything; personally I like having the extra space, but I could see some not liking the irregularity. Probably less of an issue for Chinese than it is for Japanese where furigana can be much longer than the word, especially with some kun’yomi or wonky stuff used in fiction.