
    ^h                     &    S SK r SS\S\S\4S jjrg)    Ntextwidthreturnc           	         U R                  S5      n[        S[        U5      S5       HM  nX#   R                  S5      nU Vs/ s H  n[        R                  " XQS9PM     nnSR                  U5      X#'   MO     SR                  U5      $ s  snf )aw  
Wraps text except for code blocks for nice terminal formatting.

Splits the text into paragraphs and wraps each paragraph,
except for paragraphs that are inside of code blocks denoted
by ` ``` `. Returns the updated text.

Args:
    text (str): The text to wrap.
    width (int): The width of the lines to wrap at, passed to `textwrap.fill`.

Returns:
    The wrapped text.
z```r      
)r   )splitrangelentextwrapfilljoin)r   r   blocksiparasparawrappeds          K/home/james-whalen/.local/lib/python3.13/site-packages/chatdbg/util/wrap.pyword_wrap_except_code_blocksr      s}     ZZF1c&k1%	%@EF8==3FIIg&	 &
 ::f Gs   B
)P   )r   strintr        r   <module>r      s"    s 3  r   