=====================
Python Text Justifier
=====================
.. image:: https://img.shields.io/pypi/v/justifier.svg
:target: https://pypi.python.org/pypi/text-justifier
.. image:: https://readthedocs.org/projects/text-justifier/badge/?version=latest
:target: https://text-justifier.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Justify and hyphenate text in files and/or standard input. The program can be
invoked as either **text-justifier** or **justify** .
Installation/Upgrade
--------------------
**``pip3 install -U text-justifier``**
Options
-------
``-w``, ``--width *INTEGER*``
Width of text, not counting indent
``-i``, ``--indent *INTEGER*``
Number of spaces to add before text
``-r``, ``--right-margin *INTEGER*``
Determine the width of text to suit a specific column, i.e. right margin is
indent plus width.
``-c``, ``--centre``, ``--no-centre``, ``--center``, ``--no-center``
Automatically determine line width based on terminal width, with indent
mirrored on the right. Will probably not work with indent of 0 (the
default). Uses ``$COLUMNS`` if the terminal size cannot be queried.
``-s``, ``--simple-hyphen``
Use simple hyphenation method.
``-h``, ``--hyphen``
Use *pyphen* library to hyphenate, which uses OpenOffice hyphenation
dictionaries.
``-H``, ``--no-hyphenate``
Turn hyphenation off.
* Free software: GNU General Public License v3
* Documentation: https://text-justifier.readthedocs.io. (TBA)
Features
--------
* Can centre text according to the screen/terminal width
* Indent text
TO DO
-----
* Em dashes (— or --) should be used padded before random padding is done
* Don't hyphenate URLs
* Extract URLs, replace with placeholders and dump after paragraph;
Use Markdown style or something similar i.e.
- ``[text](url)`` -> ``[text][URL_PLACEHOLDER]`` and ``[URL_PLACEHOLDER]: url``
- ``[url] -> [0]`` and ``[0]: url``
* Option (-f *n*) to add a first-line indent to each paragraph
* Option (-n) to split paragraphs on newline instead of blank lines
* Treat lines that begin with a list character as their own paragraph
Algorithm
---------
1. Grab a line's worth of text plus the word that would push it over the limit
2. Count the number of characters in the "safe" line
3. The delta equals the difference between the line length and (limit subtract
the number of full stops except one at the end of a line)
4. Determine the hyphenation threshold n = limit / 20, i.e. one extra space per
20 characters
5. If the overflow word is at least n*2 characters long, attempt to hyphenate it
6. Find the largest usable fragment of the overflow word no longer than delta - 1
7. Add the fragment if hyphenating and change delta to (delta subtract (fragment
length + 1))
8. Add a space after at most (limit subtract line length) full stops (determined randomly)
9. Add a space before and after at most delta/2 em dashes and recalculate delta
10. Add a space after delta random spaces
11. If hyphenating and the next line's delta would be greater than this one's
without hyphenation, don't hyphenate
Credits
-------
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.9.0 (2022-12-17)
------------------
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/unixnut/Python-Text-Justifier",
"name": "text-justifier",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "justifier,text formatting",
"author": "Alastair Irvine",
"author_email": "alastair@plug.org.au",
"download_url": "https://files.pythonhosted.org/packages/4c/25/a2d0b306af5f7ca08d305517319095b7dea636c552ef9c042561c8ec05ec/text-justifier-0.10.0.tar.gz",
"platform": null,
"description": "=====================\nPython Text Justifier\n=====================\n\n\n.. image:: https://img.shields.io/pypi/v/justifier.svg\n :target: https://pypi.python.org/pypi/text-justifier\n\n.. image:: https://readthedocs.org/projects/text-justifier/badge/?version=latest\n :target: https://text-justifier.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\n\n\nJustify and hyphenate text in files and/or standard input. The program can be\ninvoked as either **text-justifier** or **justify** .\n\nInstallation/Upgrade\n--------------------\n**``pip3 install -U text-justifier``**\n\nOptions\n-------\n``-w``, ``--width *INTEGER*``\n Width of text, not counting indent\n\n``-i``, ``--indent *INTEGER*``\n Number of spaces to add before text\n\n``-r``, ``--right-margin *INTEGER*``\n Determine the width of text to suit a specific column, i.e. right margin is\n indent plus width.\n\n``-c``, ``--centre``, ``--no-centre``, ``--center``, ``--no-center``\n Automatically determine line width based on terminal width, with indent\n mirrored on the right. Will probably not work with indent of 0 (the\n default). Uses ``$COLUMNS`` if the terminal size cannot be queried.\n\n``-s``, ``--simple-hyphen``\n Use simple hyphenation method.\n\n``-h``, ``--hyphen``\n Use *pyphen* library to hyphenate, which uses OpenOffice hyphenation\n dictionaries.\n\n``-H``, ``--no-hyphenate``\n Turn hyphenation off.\n\n\n* Free software: GNU General Public License v3\n* Documentation: https://text-justifier.readthedocs.io. (TBA)\n\n\nFeatures\n--------\n\n* Can centre text according to the screen/terminal width\n* Indent text\n\nTO DO\n-----\n\n* Em dashes (\u2014 or --) should be used padded before random padding is done\n\n* Don't hyphenate URLs\n\n* Extract URLs, replace with placeholders and dump after paragraph;\n Use Markdown style or something similar i.e.\n\n - ``[text](url)`` -> ``[text][URL_PLACEHOLDER]`` and ``[URL_PLACEHOLDER]: url``\n - ``[url] -> [0]`` and ``[0]: url``\n\n* Option (-f *n*) to add a first-line indent to each paragraph\n\n* Option (-n) to split paragraphs on newline instead of blank lines\n\n* Treat lines that begin with a list character as their own paragraph\n\nAlgorithm\n---------\n\n1. Grab a line's worth of text plus the word that would push it over the limit\n2. Count the number of characters in the \"safe\" line\n3. The delta equals the difference between the line length and (limit subtract\n the number of full stops except one at the end of a line)\n4. Determine the hyphenation threshold n = limit / 20, i.e. one extra space per\n 20 characters\n5. If the overflow word is at least n*2 characters long, attempt to hyphenate it\n6. Find the largest usable fragment of the overflow word no longer than delta - 1\n7. Add the fragment if hyphenating and change delta to (delta subtract (fragment\n length + 1))\n8. Add a space after at most (limit subtract line length) full stops (determined randomly)\n9. Add a space before and after at most delta/2 em dashes and recalculate delta\n10. Add a space after delta random spaces\n11. If hyphenating and the next line's delta would be greater than this one's\n without hyphenation, don't hyphenate\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.9.0 (2022-12-17)\n------------------\n\n* First release on PyPI.\n\n\n",
"bugtrack_url": null,
"license": "GNU General Public License v3",
"summary": "Justify and hyphenate text in files and/or standard input",
"version": "0.10.0",
"project_urls": {
"Homepage": "https://github.com/unixnut/Python-Text-Justifier"
},
"split_keywords": [
"justifier",
"text formatting"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "54398ae3d687c12279ec53d8e0728081a09fbb6a521185b6456882d887821d97",
"md5": "9e24d862a2025272a2e4ae656c5c3409",
"sha256": "75ff3ece90118b75c1da98fa4368b857fac381b699c7ccff16c201f96b6e9972"
},
"downloads": -1,
"filename": "text_justifier-0.10.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "9e24d862a2025272a2e4ae656c5c3409",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.5",
"size": 11350,
"upload_time": "2023-07-18T07:01:29",
"upload_time_iso_8601": "2023-07-18T07:01:29.953309Z",
"url": "https://files.pythonhosted.org/packages/54/39/8ae3d687c12279ec53d8e0728081a09fbb6a521185b6456882d887821d97/text_justifier-0.10.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4c25a2d0b306af5f7ca08d305517319095b7dea636c552ef9c042561c8ec05ec",
"md5": "fc0e788b925fd208c1525ddab26029cd",
"sha256": "6ea908cbdea1843d1d11aa48bb3cc763d2530b7df7703557cd0f639d901262a1"
},
"downloads": -1,
"filename": "text-justifier-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "fc0e788b925fd208c1525ddab26029cd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 21321,
"upload_time": "2023-07-18T07:01:31",
"upload_time_iso_8601": "2023-07-18T07:01:31.875333Z",
"url": "https://files.pythonhosted.org/packages/4c/25/a2d0b306af5f7ca08d305517319095b7dea636c552ef9c042561c8ec05ec/text-justifier-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-18 07:01:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "unixnut",
"github_project": "Python-Text-Justifier",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "text-justifier"
}