Skip to main content

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.

https://travis-ci.org/yetty/cstypo.png?branch=master https://coveralls.io/repos/yetty/cstypo/badge.png?branch=master https://pypip.in/v/cstypo/badge.png https://pypip.in/d/cstypo/badge.png

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).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cstypo-0.1.3.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file cstypo-0.1.3.tar.gz.

File metadata

  • Download URL: cstypo-0.1.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cstypo-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2b3ef02e11d46eb70d31a5a3f300d6ece8c8426904fe1223a89063f57320f4d2
MD5 7ff7ff3c2e5d1096498e7dd06f89e6cc
BLAKE2b-256 34b66d9bcf420310dd66e0cd1cf567e551ff862ade0574c4e543f6d9809dc8f0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page