cstypo
Balíček pro zkrášlení českých textů aplikováním základních typografických pravidel. Nesnaží se o pokrytí veškerých českých pravidel, spíše o aplikaci základních a to hlavně těch, které jsou na webu nejvíce vidět.
Pozor! Aplikování typografických pravidel na delší texty je poměrně výpočetně náročná operace. Zvažte kešování těchto textů.
Instalace
pip install cstypo
API
cstypo.parser.TxtParser
Výchozí třída pro zpracování textu. Použití:
parser = cstypo.parser.TxtParser(text) print parser.parser() # zformátovaný text
Je možné využít samostatně jednotlivé metody aplikující určitá pravidla:
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
Potomek třídy TxtParser, který nejdříve escapuje veškeré HTML tagy, aplikuje typografická pravidla na získaný text a vratí tagy zpět.
Django
Pro použití ve frameworku Django je připraven filtr typify v souboru cstags.
Nejdříve je potřeba cstypo přidat do INSTALLED_APPS
INSTALLED_APPS = (
...
'cstypo',
)
Poté je možné začít v šablonách používat filtr.
{% 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
CLI
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).
Metadata
Release files for cstypo 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cstypo-0.1.3.tar.gz | 6.5 kB | Without provenance | Details |
Release files / cstypo-0.1.3.tar.gz
| Download URL | cstypo-0.1.3.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b3ef02e11d46eb70d31a5a3f300d6ece8c8426904fe1223a89063f57320f4d2
|
|
BLAKE2b-256 checksum How to use checksums |
34b66d9bcf420310dd66e0cd1cf567e551ff862ade0574c4e543f6d9809dc8f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cstypo 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.