Ruby text
Attach a pronunciation guide to text such as Japanese kanji.
Ruby text adds the rubyText mark. The mark stores a reading in rt. Attach ruby_text_format to display the reading above the base text in GPUI.
Try it
Section titled “Try it”Install
Section titled “Install”cargo add gpdoc-plugin-ruby-textExample
Section titled “Example”Register the ruby text formatter in the Quickstart editor configuration. ruby_text() uses this formatter by default.
use gpdoc::{EditorConfig, PluginViewExt};use gpdoc_plugin_ruby_text::{ruby_text, ruby_text_format};use gpdoc_plugin_paragraph::paragraph;
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(ruby_text().with_view(ruby_text_format)) .build() .expect("configure editor");Apply setRubyText to selected text with a reading such as とうきょう. The formatter displays the reading above the selection.
Commands
Section titled “Commands”The mark stores its reading in rt, a nullable string with default null. editor.run returns Result<CommandOutcome, Error>. Set and toggle can return NotApplicable where the schema excludes this mark.
setRubyText
Section titled “setRubyText”Attach a reading to the selected base text, or replace the reading already there. Pass the pronunciation as rt.
editor.run(gpdoc_plugin_ruby_text::Set { rt: Some("とうきょう".into()) })?;toggleRubyText
Section titled “toggleRubyText”Remove a matching reading or apply the one supplied. At a caret inside an annotation, remove the whole contiguous reading.
editor.run(gpdoc_plugin_ruby_text::Toggle { rt: Some("とうきょう".into()) })?;unsetRubyText
Section titled “unsetRubyText”Remove the reading and keep the base text. Place the caret inside a reading to clear its contiguous range in one command.
editor.run(gpdoc_plugin_ruby_text::Unset)?;