Skip to content

Two spaces are not treated as line break in gettext builder #11737

@ivandkhn

Description

@ivandkhn

Describe the bug

Suppose we have the following Markdown file:

Some info with two images:  
![](a.png)  
![](b.png)

Note that it uses two spaces at the end of the lines to produce line breaks:

Some info with two images:<SPACE><SPACE>
![](a.png)<SPACE><SPACE>
![](b.png)

When gettext generates .po files for this document, it seems that it ignores the line breaks and threats everything as a single paragraph:

#: ../source/test.md:1
msgid "Some info with two images: ![](a.png) ![](b.png)"
msgstr ""

However, I would expect the lines to be separated:

#: ../source/test.md:1
msgid "Some info with two images:"
msgstr ""

#: ../source/test.md:3
msgid "![](a.png)"
msgstr ""

#: ../source/test.md:5
msgid "![](b.png)"
msgstr ""

How to Reproduce

Run python3 -m sphinx -b gettext source/ build/ for source/test.md:

Some info with two images:
![](a.png)
![](b.png)

build/test.pot will have the following:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2023, test
# This file is distributed under the same license as the test package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: test \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-26 10:44+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../source/test.md:1
msgid "Some info with two images: ![](a.png) ![](b.png)"
msgstr ""

Environment Information

Platform:              linux; (Linux-6.1.0-0.deb11.7-amd64-x86_64-with-glibc2.31)
Python version:        3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110])
Python implementation: CPython
Sphinx version:        5.3.0
Docutils version:      0.17.1
Jinja2 version:        2.10.3

Sphinx extensions

extensions = []

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions