Module typographer

Source
Expand description

Common textual replacements for dashes, ©, ™, …

Note: Since this plugin is most useful with smart-quotes, which is not currently implemented, this plugin is not enabled by default when using plugins::extra::add. You will have to enable it separately:

let md = &mut markdown_that::MarkdownThat::new();
markdown_that::plugins::cmark::add(md);
markdown_that::plugins::extra::add(md);
markdown_that::plugins::extra::typographer::add(md);

let html = md.parse("Hello world!.... This is the Right Way(TM) to markdown!!!!!").render();
assert_eq!(html.trim(), r#"<p>Hello world!.. This is the Right Way™ to markdown!!!</p>"#);

In summary, these are the replacements that will be made when using this:

§Typography

  • Repeated dots (...) to ellipsis () except ?... and !... which become ?.. and !.. respectively
  • +- to ±
  • Don’t repeat ? and ! more than 3 times: ???
  • De-duplicate commas
  • em and en dashes: -- to and --- to

§Common symbols (case insensitive)

  • Copyright: (c) to ©
  • Reserved: (r) to ®
  • Trademark: (tm) to

Structs§

TypographerRule

Functions§

add