SmartyPants is a Python library that converts plain ASCII punctuation in text to "smart" typographic HTML entities. It transforms straight quotes to "curly" quotes, backticks-style quotes, -- and --- to en- and em-dashes, and three consecutive dots to an ellipsis entity. The current version is 2.0.2, and it is actively maintained with recent fixes for Python 3.12+ compatibility.
pip install smartypantsVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of the smartypants function to convert ASCII punctuation to typographic entities, and how to use attributes to control conversions.
Update your code to use `smartypants.Attr` for specifying processing options (e.g., `Attr.q | Attr.d`) instead of string arguments. Refer to the official documentation for the updated API.
If smart punctuation appears unexpectedly in specific HTML tags, check if the tag is in the `tags_to_skip` list. You can modify `smartypants.tags_to_skip` or `smartypants._tags_to_skip_regex()` for advanced customization, but be aware of potential side effects.
Prepend a backslash before any punctuation character that you wish to remain as a literal ASCII character. For example, `text = "It's 6\'2\" tall."`.
Add `import smartypants` at the top of your Python file.
Use the `Attr` enum for specifying processing options. For example, `from smartypants import Attr; smartypants.smartypants(text, attrs=Attr.q | Attr.d)`.
Ensure your input text is consistently encoded, typically UTF-8. Explicitly decode input if reading from a file, for example, `text = open('input.txt', encoding='utf-8').read()`.No dependency data recorded yet.