7 releases (4 breaking)

0.5.0 Mar 12, 2024
0.4.0 Mar 11, 2024
0.3.0 Mar 10, 2024
0.2.0 Mar 9, 2024
0.1.2 Mar 9, 2024

#473 in Text processing

Download history 436/week @ 2024-03-07 48/week @ 2024-03-14 1/week @ 2024-03-21 23/week @ 2024-03-28 8/week @ 2024-04-04 13/week @ 2024-04-11 105/week @ 2024-04-18

112 downloads per month

MIT license

49KB
747 lines

About

Convert Markdown to Unicode:

Input Result
*Emphasis* ๐˜Œ๐˜ฎ๐˜ฑ๐˜ฉ๐˜ข๐˜ด๐˜ช๐˜ด
**Strong** ๐’๐ญ๐ซ๐จ๐ง๐ 
`Code` ๐™ฒ๐š˜๐š๐šŽ
~~Strike~~ Sฬถtฬถrฬถiฬถkฬถeฬถ
***Emphasis strong*** ๐‘ฌ๐’Ž๐’‘๐’‰๐’‚๐’”๐’Š๐’” ๐’”๐’•๐’“๐’๐’๐’ˆ
***Emphasis* strong** ๐‘ฌ๐’Ž๐’‘๐’‰๐’‚๐’”๐’Š๐’” ๐ฌ๐ญ๐ซ๐จ๐ง๐ 
***Strong** emphasis* ๐‘บ๐’•๐’“๐’๐’๐’ˆ ๐˜ฆ๐˜ฎ๐˜ฑ๐˜ฉ๐˜ข๐˜ด๐˜ช๐˜ด
*`Emphasis code`* โ„ฐ๐“‚๐“…๐’ฝ๐’ถ๐“ˆ๐’พ๐“ˆ ๐’ธโ„ด๐’นโ„ฏ
**`Strong code`** ๐“ข๐“ฝ๐“ป๐“ธ๐“ท๐“ฐ ๐“ฌ๐“ธ๐“ญ๐“ฎ
***`Emphasis strong code`*** โ’บโ“œโ“Ÿโ“—โ“โ“ขโ“˜โ“ข โ“ขโ“ฃโ“กโ“žโ“โ“– โ“’โ“žโ““โ“”
~~*Strike emphasis*~~ ๐˜šฬถ๐˜ตฬถ๐˜ณฬถ๐˜ชฬถ๐˜ฌฬถ๐˜ฆฬถ ฬถ๐˜ฆฬถ๐˜ฎฬถ๐˜ฑฬถ๐˜ฉฬถ๐˜ขฬถ๐˜ดฬถ๐˜ชฬถ๐˜ดฬถ
~~**Strike strong**~~ ๐’ฬถ๐ญฬถ๐ซฬถ๐ขฬถ๐คฬถ๐žฬถ ฬถ๐ฌฬถ๐ญฬถ๐ซฬถ๐จฬถ๐งฬถ๐ ฬถ
~~***Strike emphasis strong***~~ ๐‘บฬถ๐’•ฬถ๐’“ฬถ๐’Šฬถ๐’Œฬถ๐’†ฬถ ฬถ๐’†ฬถ๐’Žฬถ๐’‘ฬถ๐’‰ฬถ๐’‚ฬถ๐’”ฬถ๐’Šฬถ๐’”ฬถ ฬถ๐’”ฬถ๐’•ฬถ๐’“ฬถ๐’ฬถ๐’ฬถ๐’ˆฬถ
~~`Strike code`~~ ๐š‚ฬถ๐šฬถ๐š›ฬถ๐š’ฬถ๐š”ฬถ๐šŽฬถ ฬถ๐šŒฬถ๐š˜ฬถ๐šฬถ๐šŽฬถ
~~*`Strike emphasis code`*~~ ๐”–๐”ฑ๐”ฏ๐”ฆ๐”จ๐”ข ๐”ข๐”ช๐”ญ๐”ฅ๐”ž๐”ฐ๐”ฆ๐”ฐ ๐” ๐”ฌ๐”ก๐”ข
~~**`Strike strong code`**~~ ๐•พ๐–™๐–—๐–Ž๐–๐–Š ๐–˜๐–™๐–—๐–”๐–“๐–Œ ๐–ˆ๐–”๐–‰๐–Š
~~***`Strike emphasis strong code`***~~ ๐•Š๐•ฅ๐•ฃ๐•š๐•œ๐•– ๐•–๐•ž๐•ก๐•™๐•’๐•ค๐•š๐•ค ๐•ค๐•ฅ๐•ฃ๐• ๐•Ÿ๐•˜ ๐•”๐• ๐••๐•–

Uses pulldown-cmark and a modified version of its push_html to do real Markdown parsing and rendering. As a result, it normalizes:

  • Headings: Setext headings
  • Unordered lists: *
  • Ordered lists: numbered, .
  • Rules: ---
  • Tables

Notes

  1. This crate does not do syntax highlighting or terminal colors. For that, please check out bat and syntect.

  2. This crate outputs Unicode text using the Mathematical Alphanumeric Symbols and Enclosed Alphanumerics blocks, however your ability to see the effects depends on the specific applications (terminal, text editor, web browser, etc) you're using and their configurations (fonts, etc). For instance, it's very probable that regular and monospace look identical in a terminal or text editor, because the font is probably monospace. If a non-monospace font is configured or another application is used that uses a non-monospace font, or the output bytes are examined more closely, you will see the effect.

  3. This crate can be considered an improved version of the markdown2unicode crate but contains no copyrighted nor GPLv3 licensed code from its original upstream source (USBashka's markdown2unicode) and uses pulldown-cmark instead.

Command line

$ unidown -h
Convert Markdown to Unicode

Usage: unidown [OPTIONS] [STRING]...

Arguments:
  [STRING]...  Markdown string(s)

Options:
  -s <STYLE>      Style [possible values: italic, bold, monospace, strike,
                  bold-italic, script, bold-script, circled, strike-italic,
                  strike-bold, strike-bold-italic, strike-monospace, fraktur,
                  bold-fraktur, double-struck, all, demo]
  -i <PATH>       Input file(s)
  -r              Print readme
  -h, --help      Print help
  -V, --version   Print version
$ unidown -V
unidown 0.5.0
$ unidown 'Here is some *emphasis*, **strong**, ***strong emphasis***, ~~strike~~, and `code` text.'
Here is some ๐˜ฆ๐˜ฎ๐˜ฑ๐˜ฉ๐˜ข๐˜ด๐˜ช๐˜ด, ๐ฌ๐ญ๐ซ๐จ๐ง๐ , ๐’”๐’•๐’“๐’๐’๐’ˆ ๐’†๐’Ž๐’‘๐’‰๐’‚๐’”๐’Š๐’”, sฬถtฬถrฬถiฬถkฬถeฬถ, and ๐šŒ๐š˜๐š๐šŽ text.
$ unidown -s all 'Your text here'
๐˜ ๐˜ฐ๐˜ถ๐˜ณ ๐˜ต๐˜ฆ๐˜น๐˜ต ๐˜ฉ๐˜ฆ๐˜ณ๐˜ฆ
๐˜๐จ๐ฎ๐ซ ๐ญ๐ž๐ฑ๐ญ ๐ก๐ž๐ซ๐ž
๐šˆ๐š˜๐šž๐š› ๐š๐šŽ๐šก๐š ๐š‘๐šŽ๐š›๐šŽ
Yฬถoฬถuฬถrฬถ ฬถtฬถeฬถxฬถtฬถ ฬถhฬถeฬถrฬถeฬถ
๐’€๐’๐’–๐’“ ๐’•๐’†๐’™๐’• ๐’‰๐’†๐’“๐’†
๐’ดโ„ด๐“Š๐“‡ ๐“‰โ„ฏ๐“๐“‰ ๐’ฝโ„ฏ๐“‡โ„ฏ
๐“จ๐“ธ๐“พ๐“ป ๐“ฝ๐“ฎ๐”๐“ฝ ๐“ฑ๐“ฎ๐“ป๐“ฎ
โ“Žโ“žโ“คโ“ก โ“ฃโ“”โ“งโ“ฃ โ“—โ“”โ“กโ“”
๐˜ ฬถ๐˜ฐฬถ๐˜ถฬถ๐˜ณฬถ ฬถ๐˜ตฬถ๐˜ฆฬถ๐˜นฬถ๐˜ตฬถ ฬถ๐˜ฉฬถ๐˜ฆฬถ๐˜ณฬถ๐˜ฆฬถ
๐˜ฬถ๐จฬถ๐ฎฬถ๐ซฬถ ฬถ๐ญฬถ๐žฬถ๐ฑฬถ๐ญฬถ ฬถ๐กฬถ๐žฬถ๐ซฬถ๐žฬถ
๐’€ฬถ๐’ฬถ๐’–ฬถ๐’“ฬถ ฬถ๐’•ฬถ๐’†ฬถ๐’™ฬถ๐’•ฬถ ฬถ๐’‰ฬถ๐’†ฬถ๐’“ฬถ๐’†ฬถ
๐šˆฬถ๐š˜ฬถ๐šžฬถ๐š›ฬถ ฬถ๐šฬถ๐šŽฬถ๐šกฬถ๐šฬถ ฬถ๐š‘ฬถ๐šŽฬถ๐š›ฬถ๐šŽฬถ
๐”œ๐”ฌ๐”ฒ๐”ฏ ๐”ฑ๐”ข๐”ต๐”ฑ ๐”ฅ๐”ข๐”ฏ๐”ข
๐–„๐–”๐–š๐–— ๐–™๐–Š๐–๐–™ ๐–๐–Š๐–—๐–Š
๐•๐• ๐•ฆ๐•ฃ ๐•ฅ๐•–๐•ฉ๐•ฅ ๐•™๐•–๐•ฃ๐•–
$ unidown -s demo 'Your text here'
| Input                            | Result         | Style              |
|----------------------------------|----------------|--------------------|
| `` *Your text here* ``           | ๐˜ ๐˜ฐ๐˜ถ๐˜ณ ๐˜ต๐˜ฆ๐˜น๐˜ต ๐˜ฉ๐˜ฆ๐˜ณ๐˜ฆ | italic             |
| `` **Your text here** ``         | ๐˜๐จ๐ฎ๐ซ ๐ญ๐ž๐ฑ๐ญ ๐ก๐ž๐ซ๐ž | bold               |
| `` `Your text here` ``           | ๐šˆ๐š˜๐šž๐š› ๐š๐šŽ๐šก๐š ๐š‘๐šŽ๐š›๐šŽ | monospace          |
| `` ~~Your text here~~ ``         | Yฬถoฬถuฬถrฬถ ฬถtฬถeฬถxฬถtฬถ ฬถhฬถeฬถrฬถeฬถ | strike             |
| `` ***Your text here*** ``       | ๐’€๐’๐’–๐’“ ๐’•๐’†๐’™๐’• ๐’‰๐’†๐’“๐’† | bold-italic        |
| `` *`Your text here`* ``         | ๐’ดโ„ด๐“Š๐“‡ ๐“‰โ„ฏ๐“๐“‰ ๐’ฝโ„ฏ๐“‡โ„ฏ | script             |
| `` **`Your text here`** ``       | ๐“จ๐“ธ๐“พ๐“ป ๐“ฝ๐“ฎ๐”๐“ฝ ๐“ฑ๐“ฎ๐“ป๐“ฎ | bold-script        |
| `` ***`Your text here`*** ``     | โ“Žโ“žโ“คโ“ก โ“ฃโ“”โ“งโ“ฃ โ“—โ“”โ“กโ“” | circled            |
| `` ~~*Your text here*~~ ``       | ๐˜ ฬถ๐˜ฐฬถ๐˜ถฬถ๐˜ณฬถ ฬถ๐˜ตฬถ๐˜ฆฬถ๐˜นฬถ๐˜ตฬถ ฬถ๐˜ฉฬถ๐˜ฆฬถ๐˜ณฬถ๐˜ฆฬถ | strike-italic      |
| `` ~~**Your text here**~~ ``     | ๐˜ฬถ๐จฬถ๐ฎฬถ๐ซฬถ ฬถ๐ญฬถ๐žฬถ๐ฑฬถ๐ญฬถ ฬถ๐กฬถ๐žฬถ๐ซฬถ๐žฬถ | strike-bold        |
| `` ~~***Your text here***~~ ``   | ๐’€ฬถ๐’ฬถ๐’–ฬถ๐’“ฬถ ฬถ๐’•ฬถ๐’†ฬถ๐’™ฬถ๐’•ฬถ ฬถ๐’‰ฬถ๐’†ฬถ๐’“ฬถ๐’†ฬถ | strike-bold-italic |
| `` ~~`Your text here`~~ ``       | ๐šˆฬถ๐š˜ฬถ๐šžฬถ๐š›ฬถ ฬถ๐šฬถ๐šŽฬถ๐šกฬถ๐šฬถ ฬถ๐š‘ฬถ๐šŽฬถ๐š›ฬถ๐šŽฬถ | strike-monospace   |
| `` ~~*`Your text here`*~~ ``     | ๐”œ๐”ฌ๐”ฒ๐”ฏ ๐”ฑ๐”ข๐”ต๐”ฑ ๐”ฅ๐”ข๐”ฏ๐”ข | fraktur            |
| `` ~~**`Your text here`**~~ ``   | ๐–„๐–”๐–š๐–— ๐–™๐–Š๐–๐–™ ๐–๐–Š๐–—๐–Š | bold-fraktur       |
| `` ~~***`Your text here`***~~ `` | ๐•๐• ๐•ฆ๐•ฃ ๐•ฅ๐•–๐•ฉ๐•ฅ ๐•™๐•–๐•ฃ๐•– | double-struck      |
$ unidown -s fraktur 'Your text here'
๐”œ๐”ฌ๐”ฒ๐”ฏ ๐”ฑ๐”ข๐”ต๐”ฑ ๐”ฅ๐”ข๐”ฏ๐”ข

Library

See the API documentation.

Dependencies

~4โ€“17MB
~190K SLoC