From 3824c3fd0a76ba628f1dbae7305132c935e9de20 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Wed, 20 Dec 2023 14:46:47 +0100 Subject: [PATCH] Allow consecutive footnote references in Textile #39884 --- .../wiki_formatting/textile/redcloth3.rb | 2 +- .../wiki_formatting/textile_formatter_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index f545bdf91a..647bd6f8ba 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -1042,7 +1042,7 @@ def flush_left( text ) end def footnote_ref( text ) - text.gsub!(/\b\[([0-9]+?)\](\s)?/, + text.gsub!(/(?<=[\p{Word}\]])\[([0-9]+?)\](\s)?/, '\1\2') end diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index c1923dd074..b3b81ae122 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -770,6 +770,23 @@ def test_should_escape_bq_citations }, false) end + def test_should_allow_multiple_footnotes + text = <<~STR + Some demo[1][2] And a sentence.[1] + + fn1. One + + fn2. Two + STR + + expected = <<~EXPECTED +

Some demo12 And a sentence.[1]

+

1 One

+

2 Two

+ EXPECTED + assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '') + end + private def assert_html_output(to_test, expect_paragraph = true) -- 2.39.2