{"id":3521,"library":"jaraco-text","title":"Jaraco Text Utilities","description":"jaraco.text is a Python library offering a collection of various text manipulation utilities, including advanced text wrapping, line joining, block indentation, symbol substitution, and more. It is actively maintained with a regular release cadence, currently at version 4.2.0.","status":"active","version":"4.2.0","language":"en","source_language":"en","source_url":"https://github.com/jaraco/jaraco.text","tags":["text-processing","string-manipulation","utilities"],"install":[{"cmd":"pip install jaraco.text","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Many core functions are directly importable from the top-level `jaraco.text` package, not nested modules.","wrong":"import jaraco.text.wrap","symbol":"wrap","correct":"from jaraco.text import wrap"},{"note":"`join_lines` is part of the `join` submodule, which is itself a submodule of `jaraco.text`.","wrong":"from jaraco.text import join_lines","symbol":"join_lines","correct":"from jaraco.text.join import join_lines"},{"note":"`ellipsis_middle` resides in the `compress` submodule.","wrong":"from jaraco.text import ellipsis_middle","symbol":"ellipsis_middle","correct":"from jaraco.text.compress import ellipsis_middle"}],"quickstart":{"code":"from jaraco.text import wrap\nfrom jaraco.text.join import join_lines\nfrom jaraco.text.compress import ellipsis_middle\n\n# Example 1: Custom text wrapping with indentation\nlong_text = \"This is a very long paragraph that demonstrates the custom wrapping functionality provided by jaraco.text. It can handle various widths and indentation levels.\" \nwrapped = wrap(long_text, width=40, indent=4)\nprint(\"--- Wrapped Text ---\")\nprint(wrapped)\n\n# Example 2: Joining lines, preserving relative indentation\nlines_to_join = [\n    \"  First indented line\",\n    \"    Second deeper line\",\n    \"Third top-level line\"\n]\njoined = join_lines(lines_to_join)\nprint(\"\\n--- Joined Lines ---\")\nprint(joined)\n\n# Example 3: Shorten string with ellipsis in the middle\nvery_long_string = \"The quick brown fox jumps over the lazy dog and then takes a nap under the shade tree.\"\nshortened = ellipsis_middle(very_long_string, max_len=30)\nprint(\"\\n--- Ellipsis Middle ---\")\nprint(shortened)\n","lang":"python","description":"This quickstart demonstrates three common utilities from jaraco.text: `wrap` for custom text wrapping, `join_lines` for combining lines while preserving indentation, and `ellipsis_middle` for shortening long strings by placing an ellipsis in the center."},"warnings":[{"fix":"Upgrade to Python 3.9+ or pin `jaraco.text<4` in your project dependencies.","message":"Version 4.0.0 and above dropped support for Python versions older than 3.9. Users on Python 3.8 or earlier must use jaraco.text version 3.x.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Be mindful of which `wrap` function you are importing and using. If you intend to use `textwrap.wrap`, explicitly import `from textwrap import wrap`.","message":"The `wrap` function in `jaraco.text` is distinct from the standard library's `textwrap.wrap`. While similar in concept, it has different parameters (e.g., `indent` instead of `initial_indent`/`subsequent_indent`) and may behave differently.","severity":"gotcha","affected_versions":"All"},{"fix":"Consult the documentation or source code to find the correct import path for the specific utility you need. For example, `from jaraco.text.join import join_lines`.","message":"Many utilities like `join_lines` or `ellipsis_middle` are nested within submodules (e.g., `jaraco.text.join`, `jaraco.text.compress`) and must be imported from their specific paths, not directly from `jaraco.text`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}