Socket
Socket
Sign inDemoInstall

richtypo

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    richtypo

The only web typograph that don't make a mess out of your text. Russian and English supported.


Maintainers
1

Readme

Richtypo — the only web typograph that don't make a mess out of your text

Richtypo assumes that your text already has right dashes and quotes. The main concern is to add non-breaking spaces to the right places.

This project is heavily inspired by Artem Sapegin's richtypo.

PyPI version Build Status codecov

Features

  • Blazing fast, aimed for render-time usage.
  • Native Russian support.
  • HTML, Markdown and Plain-text aware, does not break your markup.
  • Your text stays readable and indexable — richtypo does not produce HTML entities and other messy stuff.
  • Easy integration with Jinja2, Django templates and any other language.
  • Well tested Python3 and Python2 support. For py2 only unicode input is accepted.
  • Easily extendable through smallest possible regular expressions defined in YAML with in-place specifications.

Installation

pip install richtypo

Usage

from richtypo import Richtypo


r = Richtypo(ruleset='ru-lite')

well_done = r.richtypo(text)

Jinja2 filter

from richtypo.filter import filter

env = jinja2.Environment(
    filters={
        'richtypo': filter
    }
)

Template:

{{ text | richtypo('ru-lite') }}

Django filter

# your_app/templatetags/richtypo.py

from django import template
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
from richtypo.filter import filter as typograph

register = template.Library()


@register.filter
@stringfilter
def richtypo(value, ruleset='generic'):
    return mark_safe(typograph(value, ruleset))

Template:

{% load richtypo %}

{{ object.text | richtypo:"ru-lite"}}

License

MIT

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc