sabberworm / python-markdown-latuni

Convert markdown to unicode-formatted "plain text"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python-markdown-latuni: Convert markdown to formatted "plain text"

The Unicode specification allows a lot of glyphs that would normally require special fonts to now be available in "plain text" files. Chess pieces, mathematical symbols, etc.

Unicode even contains variants for the basic Latin alphabet in 𝐛𝐨π₯𝐝, π‘–π‘‘π‘Žπ‘™π‘–π‘, 𝒃𝒐𝒍𝒅 π’Šπ’•π’‚π’π’Šπ’„, πš–πš˜πš—πš˜πšœπš™πšŠπšŒπšŽ, and π•žπ• π•£π•–. My other python module, LatUni, flagrantly abuses this fact to allow you to add text formatting to "plain text" files. This module, python-markdown-latuni, takes this abuse one step further and lets you generate unicode-formatted "plain text" from markdown, via the python Markdown module.

Disclaimer: This is a novelty, and probably breaks some accessibility rules or something. There is also probably some software which won't be able to handle text formatted in this way. (A lot of unicode-aware software still has trouble handling actually meaningful use cases like R-to-L text.)


As much as anything else, this was to help me learn python package/module distribution. If I've done it right, you should be able to do the standard python3 install (or python3 develop if you want to hack around with me on this mess).

Standalone Script

Once you install this module, you'll have a script in your path called md2latuni. It reads markdown text from the given input file (or standard input by default) and writes the unicode-formatted output to the given output file (or standard output). It automatically loads the smarty markdown extension to give the right unicode glyphs for single and double quotees. You can add other markdown extensions to the list as well; see md2latuni --help.

Markdown Plugin

Usage is like any standard Markdown plugin:

md = markdown.Markdown(
md.stripTopLevelTags = False
out = md.convert(text)

The style "sans" is default; "serif" is also available. This just tells latuni which variant of bold and italic text it should be using.

Future Plans

  • Text-wrapping
  • Distinguishing headers
  • Handling bullets
  • Handling hyperlinks
  • Handling blockquotes

Have Fun

Because that's all this is for.

ezoic increase your site revenue


Convert markdown to unicode-formatted "plain text"

License:MIT License


Language:Python 100.0%