Welcome to Typus¶
Typus is a typography tool. It means your can write text the way you use to and let it handle all that formating headache:
"I don't feel very much like Pooh today..." said Pooh. "There there," said Piglet. "I'll bring you tea and honey until you do." - A.A. Milne, Winnie-the-Pooh “I don’t feel very much like Pooh today…” said Pooh. “There there,” said Piglet. “I’ll bring you tea and honey until you do.” — A. A. Milne, Winnie-the-Pooh
Copy & paste this example to your rich text editor. Result may depend on
the font of your choice.
For instance, there is a tiny non-breaking space between
A. A. you
can see with Helvetica:
Try out the demo.
$ pip install git+git://github.com/byashimov/typus.git#egg=typus
Currently Typus supports English and Russian languages only. But it doesn’t mean it can’t handle more. I’m quite sure it covers Serbian and Turkmen.
In fact, Typus doesn’t make difference between languages. It works with text. If you use Cyrillic then only relative processors will affect that text. In another words, give it a try if your language is not on the list
Here is a short example:
>>> from typus import en_typus, ru_typus ... >>> # Underscore is for nbsp in debug mode >>> en_typus('"Beautiful is better than ugly." (c) Tim Peters.', debug=True) '“Beautiful is_better than ugly.” ©_Tim Peters.' >>> # Cyrillic 'с' in '(с)' >>> ru_typus('"Красивое лучше, чем уродливое." (с) Тим Петерс.', debug=True) '«Красивое лучше, чем уродливое.» ©_Тим Петерс.'
The only difference between
are in quotes they set:
“‘’” for English and
«„“» for Russian. Both of
them handle mixed text and that is pretty awesome.
Typus is highly customizable. Not only quotes can be replaced but almost
everything. For instance, if you don’t use html tags you can skip
EscapeHtml processor which makes your Typus a little
What it does¶
- Replaces regular quotes
"foo 'bar' baz"with typographic pairs:
“foo ‘bar’ baz”. Quotes style depends on language and your Typus configuration.
- Replaces regular dash
foo - barwith mdash or ndash or minus. Depends on case: plain text, digit rage, phone nubers, etc.
- Replaces complex symbols such as
(c)with unicode characters:
©. Cyrillic analogs are supported too.
- Replaces vulgar fractions
1/2with unicode characters:
- Turns multiply symbol to a real one:
- Replaces quotes with primes:
- Puts non-breaking spaces.
- Puts ruble symbol.
- Trims spaces at the end of lines.
- and much more.
Docs are hosted on readthedocs.org.
Oh, there is also an outdated Russian article I should not probably suggest, but since all docs are in English, this link might be quite helpful.
Tested on Python 3.6, 3.7.
- Python 3.6 and higher are supported only. However should work on any 3.x branch. That’s because 3.6 string formatting is used in tests to make them easier to read and write.
EnRuExpressionsis no longer a mixin but processor.
- Better, cleaner tests with pytest.
- Minor fixes and improvements.
- Initial release.