Skip to content

Latest commit

ย 

History

History
88 lines (64 loc) ยท 2.51 KB

File metadata and controls

88 lines (64 loc) ยท 2.51 KB

Math Text Transform

Travis build crates.io

A simple crate that provides functions to map a greek letter, latin letter, or a decimal digit to a certain variant from the mathematical alphanumeric symbols Unicode block (U+1D400โ€“U+1D7FF). We also provide convenience string methods that maps each character in a string to the variant (or leaves it alone if there is none).

Supported variants are:

  • ๐›๐จ๐ฅ๐ (bold)
  • ๐‘–๐‘ก๐‘Ž๐‘™๐‘–๐‘ (italic)
  • ๐’ƒ๐’๐’๐’… ๐’Š๐’•๐’‚๐’๐’Š๐’„ (bold italic)
  • ๐—Œ๐–บ๐—‡๐—Œ-๐—Œ๐–พ๐—‹๐—‚๐–ฟ (sans-serif)
  • ๐˜€๐—ฎ๐—ป๐˜€-๐˜€๐—ฒ๐—ฟ๐—ถ๐—ณ ๐—ฏ๐—ผ๐—น๐—ฑ (sans-serif bold)
  • ๐˜ด๐˜ข๐˜ฏ๐˜ด-๐˜ด๐˜ฆ๐˜ณ๐˜ช๐˜ง ๐˜ช๐˜ต๐˜ข๐˜ญ๐˜ช๐˜ค (sans-serif italic)
  • ๐™จ๐™–๐™ฃ๐™จ-๐™จ๐™š๐™ง๐™ž๐™› ๐™—๐™ค๐™ก๐™™ ๐™ž๐™ฉ๐™–๐™ก๐™ž๐™˜ (sans-serif bold italic)
  • ๐“ˆ๐’ธ๐“‡๐’พ๐“…๐“‰ (script)
  • ๐“ซ๐“ธ๐“ต๐“ญ ๐“ผ๐“ฌ๐“ป๐“ฒ๐“น๐“ฝ (bold script)
  • ๐”ฃ๐”ฏ๐”ž๐”จ๐”ฑ๐”ฒ๐”ฏ (fraktur)
  • ๐–‡๐–”๐–‘๐–‰ ๐–‹๐–—๐–†๐–๐–™๐–š๐–— (bold fraktur)
  • ๐š–๐š˜๐š—๐š˜๐šœ๐š™๐šŠ๐šŒ๐šŽ (monospace)
  • ๐••๐• ๐•ฆ๐•“๐•๐•–-๐•ค๐•ฅ๐•ฃ๐•ฆ๐•”๐•œ (double-struck)

Install

Add this to your Cargo.toml:

[dependencies]
math-text-transform = "*"

Usage

extern crate math_text_transform;
use math_text_transform::MathTextTransform;

assert_eq!("Bold".to_math_bold(), "๐๐จ๐ฅ๐");
assert_eq!("ฮฃฮฑฮฝฯƒ-ฮฃฮตฯฮนฯ†-ฮ’ฮฟฮปฮด".to_math_sans_serif_bold(), "๐จ๐ฐ๐ผ๐ž‚-๐จ๐ด๐ž€๐ธ๐ž…-๐—๐พ๐บ๐ณ");
assert_eq!("Double-struck 123".to_math_double_struck(), "๐”ป๐• ๐•ฆ๐•“๐•๐•–-๐•ค๐•ฅ๐•ฃ๐•ฆ๐•”๐•œ ๐Ÿ™๐Ÿš๐Ÿ›");

Documentation

https://runarberg.github.com/math-text-transform

CLI utility

If you are for some reason only interested in the CLI utility you can install with:

$ git clone https://github.com/runarberg/math-text-transform.git
$ cd math-text-transform
$ cargo build --release
$ [sudo] ln -s $(pwd)/target/release/math-text-transform /usr/local/bin/math-text-transform

And use like so:

math-text-transform <variant> <text>

Text can also be supplied through the standard input.

Examples

$ math-text-transform -bf-it Bold-Italic
๐‘ฉ๐’๐’๐’…-๐‘ฐ๐’•๐’‚๐’๐’Š๐’„
$ echo "Double struck" | math-text-transform --double-struck
๐”ป๐• ๐•ฆ๐•“๐•๐•– ๐•ค๐•ฅ๐•ฃ๐•ฆ๐•”๐•œ