Skip to content

RichText: Adapt the new line handling #1

Done

Description

@cvas22

Copied from python-docx-template issue 43, opened by @DennyWeinberg on 2016-06-17.


In the RichText class we need to replace the line
text = escape(text).replace('\n','<w:br/>')

by
text = escape(text).replace('\r\n', '<w:br/>').replace('\r', '<w:br/>').replace('\n', '<w:br/>')

because we uses sometimes only \r and in this case the first line does not work.

Activity

  1. cvas22 commented on Nov 25, 2026

    @cvas22
    OwnerAuthor

    @DennyWeinberg this one took a while. \r\n and a bare \r now become line breaks the same as \n, for plain strings and RichText. Fixed in #207, it'll be in the next docform release.

  2. added a commit that references this issue on Nov 25, 2026
    6c3d7eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions