File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 11### master
22
3+ #### Bug fixes
4+
5+ * Fixed bad coloring of some RDoc-style docs
6+ (([ #2182 ] ( https://github.com/pry/pry/pull/2182 ) )
7+
38### [ v0.14.0] [ v0.14.0 ] (February 8, 2021)
49
510#### Features
Original file line number Diff line number Diff line change @@ -17,12 +17,13 @@ def process_rdoc(comment)
1717 last_match_ruby = proc do
1818 SyntaxHighlighter . highlight ( Regexp . last_match ( 1 ) )
1919 end
20+
2021 comment . gsub ( %r{<code>(?:\s *\n )?(.*?)\s *</code>}m , &last_match_ruby )
2122 . gsub ( %r{<em>(?:\s *\n )?(.*?)\s *</em>}m ) { "\e [1m#{ Regexp . last_match ( 1 ) } \e [0m" }
2223 . gsub ( %r{<i>(?:\s *\n )?(.*?)\s *</i>}m ) { "\e [1m#{ Regexp . last_match ( 1 ) } \e [0m" }
2324 . gsub ( %r{<tt>(?:\s *\n )?(.*?)\s *</tt>}m , &last_match_ruby )
2425 . gsub ( /\B \+ (\w +?)\+ \B / ) { "\e [32m#{ Regexp . last_match ( 1 ) } \e [0m" }
25- . gsub ( /((?:^[ \t ]+.+(?:\n +|\Z ))+)/ , &last_match_ruby )
26+ . gsub ( /((?:^[ \t ]+(?:(?!.+ \e \[ )) .+(?:\n +|\Z ))+)/ , &last_match_ruby )
2627 . gsub ( /`(?:\s *\n )?([^\e ]*?)\s *`/ ) { "`#{ last_match_ruby . call } `" }
2728 end
2829
Original file line number Diff line number Diff line change 7272 it "should not remove ++" do
7373 expect ( @helper . process_rdoc ( "--\n comment in a bubble\n ++" ) ) . to match ( /\+ \+ / )
7474 end
75+
76+ it "should not syntax highlight already highlighted code" do
77+ expect ( @helper . process_rdoc ( " \e \[ 31mFOO\e \[ 0m" ) ) . to match ( / \e \[ 31mFOO\e \[ 0m/ )
78+ end
7579 end
7680end
You can’t perform that action at this time.
0 commit comments