A pre-commit fixer for replacing "smartquote" characters.
Project description
fix-smartquotes
A pre-commit hook for automatically finding and replacing smartquote
characters with the standard ascii "
and '
characters.
This fixes copy-paste from some applications which replace double-quotes with curly quotes. It does not convert corner brackets, braile quotation marks, or angle quotation marks. Those characters are not typically the result of copy-paste errors, so they are allowed.
Low quotation marks vary in usage and meaning by language, and some languages use quotation marks which are facing "outwards" (opposite facing from english). For the most part, these and exotic characters (double-prime quotes) are ignored.
In files with the offending marks, they are replaced and the run is marked as failed.
Supported Hooks
Only one hook is provided, fix-smartquotes
.
Use it in .pre-commit-config.yaml
like so:
- repo: https://github.com/sirosen/fix-smartquotes
rev: 0.1.1
hooks:
- id: fix-smartquotes
Overriding Quotation Characters
Two options are available for specifying exactly which characters will be replaced. For ease of use, they are specified as hex-encoded unicode codepoints.
Suppose you wanted to avoid replacing the "Heavy single comma quotation
mark ornament" (275C
) and the "Heavy single turned comma quotation mark
ornament" (275B
) characters. You could override the single quote codepoints
as follows:
- repo: https://github.com/sirosen/fix-smartquotes
rev: 0.1.1
hooks:
- id: fix-smartquotes
# replace default single quote chars with this set:
# apostrophe, fullwidth apostrophe, left single quote, single high
# reversed-9 quote, right single quote
args: ["--single-quote-codepoints", "0027,FF07,2018,201B,2019"]
Standalone Usage
You can also pip install fix-smartquotes
to run the tool manually.
For full usage info:
fix-smartquotes --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for fix_smartquotes-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d88895466a9a95e1cd107b75872d9c59c595d6396656071d640e58683baa89a5 |
|
MD5 | 80c85bebfd43e0699c4a0d59a545b67e |
|
BLAKE2b-256 | 52330f1e46e89cad861ed841e83f1fcefeb5bb56d4e2e4aa5381051217e4fc50 |