Add ruby
例解学習国語 places readings beside kanji throughout its 雀 article.
Use an unfinished dictionary writer and add the fragment before writing the article XML.
Add ruby
label = mkd.InlineText()
label.append(mkd.Ruby("鶫", "つぐみ"))
MKD::InlineText label;
label.append(MKD::Ruby{"鶫", "つぐみ"});
The ruby pairs the written form 鶫 with its reading つぐみ.
Use the formatted text
After assembling the label, encode it for the intended destination:
fragment = label.to_xml()
headline = label.to_headline()
auto fragment = label.toXhtml().value();
auto headline = label.toHeadline().value();
Insert fragment into article XML before writing it. Use headline as a
HeadlineComponents headline. XML ruby uses <ruby><rb>鶫</rb><rt>つぐみ</rt></ruby>.
Headlines use a separate native encoding.
Configure full-ruby presentation
dictionary.add_asset("ruby.css", mkd.Buffer.map("ruby.css"))
dictionary.set_presentation(mkd.DictionaryPresentation(full_ruby_stylesheet="ruby.css"))
auto css = MKD::RetainedSpan::map("ruby.css").value();
dictionary.addAsset("ruby.css", css.span()).value();
dictionary.setPresentation({.fullRubyStylesheet = "ruby.css"}).value();
This records the stylesheet for the native full-ruby presentation. It controls readings already in the article XML. See Ruby presentation for the CSS. Finish the dictionary and product as in the first dictionary.
The generic kanwa headline formatter does not interpret general ruby headline tokens. Keep its compound headlines as plain text and use ruby in article XML.
Next: Add gaiji.
