Project

General

Profile

Actions

Defect #43730

open

Redmine generates invalid HTML when there are multiple `collapse` macros in one paragraph in Textile

Added by Artem Varaksa 22 days ago. Updated about 4 hours ago.

Status:
Confirmed
Priority:
Normal
Category:
Text formatting
Resolution:
Affected version:

Description

The issue has been observed last year on around January 21, 2025, though the behavior has been noted earlier. It's reproducible in the Redmine version on redmine.org and on 6+ versions as well.

Example 1 (one group - incorrect) + description

1 {{collapse(1)
1
}}
2 {{collapse(2)
2
}}
3 {{collapse(3)
3
}}

Resulting HTML

Formatted HTML

Validation with https://validator.w3.org/nu/#textarea highlights the following main issue:

Browsers fix these kinds of HTML issues (in this case, by opening the "p" tag in the end before its closure), but this is not the intended markup. All of these collapses should be inside a single "p" tag.

In Redmine, the result is this:

1 1


2 2
3 3

Screenshot:

I.e. the first collapse in a group is separated from others by a big blank space.

Workaround 1: splitting collapses by newlines. However, this results in a different markup - between each collapse, there will be a blank space (though, a smaller one) - and it's impossible to group several collapses together in one logical section.

Workaround 2: using a list. However, this is also a different markup that may not be always applicable and it increases logical complexity of the formatting.

See more examples below.

Example 2 (without extra text - incorrect)

{{collapse(1)
1
}}
{{collapse(2)
2
}}
{{collapse(3)
3
}}

Result:

1

2 3

Screenshot:

Example 3 (several groups - incorrect)

1 {{collapse(1)
1
}}
2 {{collapse(2)
2
}}
3 {{collapse(3)
3
}}

4 {{collapse(4)
4
}}
5 {{collapse(5)
5
}}
6 {{collapse(6)
6
}}

Result:

1 1


2 2
3 3

4 4


5 5
6 6

Screenshot:

Example 4: Workaround 1 (all separate - correct, but impossible to group)

1 {{collapse(1)
1
}}

2 {{collapse(2)
2
}}

3 {{collapse(3)
3
}}

Result:

1 1

2 2

3 3

Screenshot:

Example 5: Workaround 2 (list - correct)

* 1 {{collapse(1)
1
}}
* 2 {{collapse(2)
2
}}
* 3 {{collapse(3)
3
}}

Result:

Screenshot:


Files

Actions #1

Updated by Artem Varaksa 21 days ago

We were able to reproduce this behavior on a clean Redmine installation with the following configuration (changed formatting to "Textile" and adjusted the "Welcome text" field by adding the aforementioned examples):

Environment:
  Redmine version                6.1.1.stable
  Ruby version                   3.3.8-p144 (2025-04-09) [x86_64-linux]
  Rails version                  7.2.3
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Default
SCM:
  Git                            2.50.1
  Filesystem                     
Redmine plugins:
  no plugin installed
Actions #2

Updated by Marius BĂLTEANU about 4 hours ago

  • Status changed from New to Confirmed
  • Assignee set to Marius BĂLTEANU
  • Target version set to 6.0.9

The problem is that the text (in your example, 1, 2 and 3) is wrapped in a p tag, the macro is wrapped in a div tag and div inside p is not valid.

Actions #3

Updated by Marius BĂLTEANU about 4 hours ago

  • Target version changed from 6.0.9 to Candidate for next minor release
Actions

Also available in: Atom PDF