diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-11-27 20:15:54 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-11-27 15:58:31 +0000 |
commit | 196c4aeb766a66b3557ddab61086db58c7a08226 (patch) | |
tree | 46545600783f75d9d928af9ff3c21029315a58f0 /lib/rdoc | |
parent | 7835ebce97a6e6132d2bc7bdbef115f3f47cc6c2 (diff) |
[ruby/rdoc] Place a space between certain character class letters only
https://github.com/ruby/rdoc/commit/1f568e049d
Diffstat (limited to 'lib/rdoc')
-rw-r--r-- | lib/rdoc/markup/parser.rb | 2 | ||||
-rw-r--r-- | lib/rdoc/markup/to_html.rb | 4 | ||||
-rw-r--r-- | lib/rdoc/text.rb | 6 |
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb index 0029df7e65..2ad4a65808 100644 --- a/lib/rdoc/markup/parser.rb +++ b/lib/rdoc/markup/parser.rb @@ -218,7 +218,7 @@ class RDoc::Markup::Parser break if peek_token.first == :BREAK - data << ' ' if skip :NEWLINE + data << ' ' if skip :NEWLINE and /#{SPACE_SEPARATED_LETTER_CLASS}\z/o.match?(data) else unget break diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index 6c9f5733a2..fb38924a04 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -202,7 +202,9 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter def accept_paragraph paragraph @res << "\n<p>" text = paragraph.text @hard_break - text = text.gsub(/\r?\n/, ' ') + text = text.gsub(/(#{SPACE_SEPARATED_LETTER_CLASS})?\K\r?\n(?=(?(1)(#{SPACE_SEPARATED_LETTER_CLASS})?))/o) { + defined?($2) && ' ' + } @res << to_html(text) @res << "</p>\n" end diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 0bc4aba428..6f1a2b8d15 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -309,4 +309,10 @@ module RDoc::Text res.join.strip end + ## + # Character class to be separated by a space when concatenating + # lines. + + SPACE_SEPARATED_LETTER_CLASS = /[\p{Nd}\p{Lc}\p{Pc}]/ + end |