Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Typogrify provides a set of custom filters that automatically apply various transformations to plain text in order to yield typographically-improved HTML. While often used in conjunction with Jinja_ and Django_ template systems, the filters can be used in any environment.
.. _Jinja: http://jinja.pocoo.org/ .. _Django: https://www.djangoproject.com/
The following command will install via pip
. Pay particular attention to the
package name::
pip install typogrify
Alternatively, you can run the following command inside the project's root directory::
python setup.py install
Last but not least, you can simply move the enclosed typogrify
folder
into your Python path.
Python 2.3 and above is supported, including Python 3. The only dependency is SmartyPants_, a Python port of a project by John Gruber.
Installing Jinja_ or Django_ is only required if you intend to use the optional template filters that are included for those frameworks.
.. _SmartyPants: http://web.chad.org/projects/smartypants.py/
The filters can be used in any environment by importing them from
typogrify.filters
::
from typogrify.filters import typogrify
content = typogrify(content)
For use with Django, you can add typogrify
to the INSTALLED_APPS
setting
of any Django project in which you wish to use it, and then use
{% load typogrify_tags %}
in your templates to load the filters it provides.
Experimental support for Jinja is in typogrify.templatetags.jinja_filters
.
amp
Wraps ampersands in HTML with <span class="amp">
so they can be
styled with CSS. Ampersands are also normalized to &
. Requires
ampersands to have whitespace or an
on both sides. Will not
change any ampersand which has already been wrapped in this fashion.
caps
Wraps multiple capital letters in <span class="caps">
so they can
be styled with CSS.
initial_quotes
Wraps initial quotes in <span class="dquo">
for double quotes or
<span class="quo">
for single quotes. Works inside these block
elements:
h1
, h2
, h3
, h4
, h5
, h6
p
li
dt
dd
Also accounts for potential opening inline elements: a
, em
,
strong
, span
, b
, i
.
smartypants
Applies SmartyPants
.
typogrify
Applies all of the following filters, in order:
amp
widont
smartypants
caps
initial_quotes
widont
Based on Shaun Inman's PHP utility of the same name, replaces the
space between the last two words in a string with
to avoid
a final line of text with only one word.
Works inside these block elements:
h1
, h2
, h3
, h4
, h5
, h6
p
li
dt
dd
Also accounts for potential closing inline elements: a
, em
,
strong
, span
, b
, i
.
FAQs
Filters to enhance web typography, including support for Django & Jinja templates
We found that typogrify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.