autoruby

Crates.ioautoruby
lib.rsautoruby
version0.5.1
sourcesrc
created_at2023-02-01 16:35:44.825135
updated_at2023-10-25 20:12:13.066545
descriptionEasily generate furigana for various document formats
homepage
repositoryhttps://github.com/encody/autoruby
max_upload_size
id773913
size33,801
Jacob Lindahl (encody)

documentation

https://docs.rs/autoruby

README

autoruby

Automatically generate furigana/ruby for various document formats.

Example

use autoruby::{annotate, format, select};

let input = "神は「光あれ」と言われた。すると光があった。";
let expected = "[神]{かみ}は「[光]{ひかり}あれ」と[言]{い}われた。すると[光]{ひかり}があった。";
let annotator = annotate::Annotator::new_with_integrated_dictionary();
let annotated = annotator.annotate(input);
let result = annotated.render(&select::heuristic::All, &format::Markdown);

assert_eq!(result, expected);

Setup

The tool works using an embedded database of the JMdict furigana as provided by Doublevil.

To generate the database for yourself, first download the text file either manually from the above link, or enable the integrated feature.

If the integrated feature is enabled, you can run the build.rs script to compile the dictionary into a binary database. (It will run automatically, either by your IDE or when running cargo build.) The dictionary and database files will be saved to path in the OUT_DIR environment variable.

Contributing

If you are making modifications to the code and rebuilding it often, you probably don't want to re-download the furigana dictionary for every rebuild. To avoid this, copy the .env.example file and rename it to .env. The build script will download the furigana dictionary to the directory specified by the AUTORUBY_CACHE_DIR (default: ./cache) and reuse it for subsequent builds.

Future work

  • EPUB support

Authors

Commit count: 65

cargo fmt