轻松应用捷克语排版的软件包
项目描述
一个通过应用基本排版规则来美化捷克语文本的软件包。它不试图覆盖所有捷克语规则,而是主要应用基本的、在网页上最常看到的规则。
注意! 对较长的文本应用排版规则是一个相对计算密集的操作。请考虑对这些文本进行缓存。
安装
pip install cstypo
API
cstypo.parser.TxtParser
处理文本的默认类。用法
parser = cstypo.parser.TxtParser(text) print parser.parser() # zformátovaný text
可以单独使用应用特定规则的方法
cstypo.parser.TxtParser.parse_ellipsis
cstypo.parser.TxtParser.parse_en_dash
cstypo.parser.TxtParser.parse_em_dash
cstypo.parser.TxtParser.parse_dates
cstypo.parser.TxtParser.parse_arrows
cstypo.parser.TxtParser.parse_plusminus
cstypo.parser.TxtParser.parse_dimension
cstypo.parser.TxtParser.parse_quotes
cstypo.parser.TxtParser.parse_prepositions
cstypo.parser.TxtParser.parse_last_short_word
cstypo.parser.HtmlParser
是TxtParser类的子类,它首先转义所有HTML标签,将排版规则应用到获取到的文本上,然后返回标签。
Django
在Django框架中使用时,cstags文件中提供了typify过滤器。
首先需要将cstypo添加到INSTALLED_APPS中
INSTALLED_APPS = ( ... 'cstypo', )
然后可以在模板中使用过滤器。
{% load cstags %} {{ text|typify }} # zpracování obyčejného textu (výchozí) {{ text|typify:'txt' }} # ... {{ text|typify:'html' }} # zpracování html {{ text|typify:'html'|safe }} # pro povolení vypsání je potřeba filter safe
命令行界面
cstypo Usage: cstypo [--type (txt|html)] <input> cstypo -h | --help cstypo -v | --version Options: -h --help show this screen. -v --version show version. --type type of parsed file (txt default).
项目详情
关闭
cstypo-0.1.3.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2b3ef02e11d46eb70d31a5a3f300d6ece8c8426904fe1223a89063f57320f4d2 |
|
MD5 | 7ff7ff3c2e5d1096498e7dd06f89e6cc |
|
BLAKE2b-256 | 34b66d9bcf420310dd66e0cd1cf567e551ff862ade0574c4e543f6d9809dc8f0 |