Skip to content
Myr

add break_on_hyphens parameter to wordwrap filter

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Alessandro -oggei- Ogier · committed by David Lord · parent 881c56b · Browse files · 2 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−1 removed

  • other:+17 added−1 removed

2 files+17 added−1 removed

modified:jinja2/filters.py+15 added-1 removed
682 unmodified lines
683 return result + end684685686@environmentfilter687def do_wordwrap(environment, s, width=79, break_long_words=True, wrapstring=None):687def do_wordwrap(688 environment,689 s,690 width=79,691 break_long_words=True,692 wrapstring=None,693 break_on_hyphens=True,694):695 """Wrap a string to the given width. Existing newlines are treated696 as paragraphs to be wrapped separately.697698 :param s: Original text to wrap.699 :param width: Maximum length of wrapped lines.700 :param break_long_words: If a word is longer than ``width``, break701 it across lines.702 :param break_on_hyphens: If a word contains hyphens, it may be split703 across lines.704 :param wrapstring: String to join each wrapped line. Defaults to705 :attr:`Environment.newline_sequence`.706707 .. versionchanged:: 2.11708 Existing newlines are treated as paragraphs wrapped separately.709710 .. versionchanged:: 2.11711 Added the ``break_on_hyphens`` parameter.712713 .. versionchanged:: 2.7714 Added the ``wrapstring`` parameter.715 """716717 import textwrap718719 if not wrapstring:720 wrapstring = environment.newline_sequence
10 unmodified lines
731 width=width,732 expand_tabs=False,733 replace_whitespace=False,734 break_long_words=break_long_words,735 break_on_hyphens=break_on_hyphens,736 )737 )738 for line in s.splitlines()739 ]
613 unmodified lines
modified:CHANGES.rst+2 added
63 unmodified lines
64 system encoding. :issue:`889`65- ``|wordwrap`` filter treats existing newlines as separate paragraphs66 to be wrapped individually, rather than creating short intermediate67 lines. :issue:`175`68- Add ``break_on_hyphens`` parameter to ``|wordwrap`` filter.69 :issue:`550`707172Version 2.10.373--------------
629 unmodified lines