From 41ad3191e9189d8bb504a9fb566fb9507ceb30b3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 14 Nov 2023 16:23:36 +0900 Subject: [PATCH] Fix TIDYLINK after braces (#1015) TIDYLINK multi-word label should not include braces. --- lib/rdoc/markup/formatter.rb | 2 +- test/rdoc/test_rdoc_markup_formatter.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb index 37a2c2751a..9daffaabb8 100644 --- a/lib/rdoc/markup/formatter.rb +++ b/lib/rdoc/markup/formatter.rb @@ -90,7 +90,7 @@ def add_regexp_handling_RDOCLINK def add_regexp_handling_TIDYLINK @markup.add_regexp_handling(/(?: - \{.*?\} | # multi-word label + \{[^{}]*\} | # multi-word label \b[^\s{}]+? # single-word label ) diff --git a/test/rdoc/test_rdoc_markup_formatter.rb b/test/rdoc/test_rdoc_markup_formatter.rb index 8702db379d..af19d832ca 100644 --- a/test/rdoc/test_rdoc_markup_formatter.rb +++ b/test/rdoc/test_rdoc_markup_formatter.rb @@ -104,6 +104,12 @@ def @to.handle_regexp_TIDYLINK target formatted = document.accept @to assert_equal '<{foo}[rdoc-label:bar]>.', formatted + + document = doc(para('{abc}: {foo}[rdoc-label:bar].')) + + formatted = document.accept @to + + assert_equal '{abc}: <{foo}[rdoc-label:bar]>.', formatted end def test_parse_url