1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Merge pull request #1440 from egwspiti/master

Syntax highlight <tt> tags in documentation output.
This commit is contained in:
Kyrylo Silin 2015-06-24 16:51:30 +03:00
commit 42ff1b633c
3 changed files with 6 additions and 0 deletions

View file

@ -1,5 +1,6 @@
### HEAD
* Syntax highlight <tt> tags in documentation output.
* Add support for BasicObject subclasses who implement their own #inspect (#1341)
* Fix 'include RSpec::Matchers' at the top-level (#1277)
* Add 'gem-readme' command, prints the README file bundled with a rubygem

View file

@ -12,6 +12,7 @@ class Pry
comment.gsub(/<code>(?:\s*\n)?(.*?)\s*<\/code>/m) { CodeRay.scan($1, :ruby).term }.
gsub(/<em>(?:\s*\n)?(.*?)\s*<\/em>/m) { "\e[1m#{$1}\e[0m" }.
gsub(/<i>(?:\s*\n)?(.*?)\s*<\/i>/m) { "\e[1m#{$1}\e[0m" }.
gsub(/<tt>(?:\s*\n)?(.*?)\s*<\/tt>/m) { CodeRay.scan($1, :ruby).term }.
gsub(/\B\+(\w+?)\+\B/) { "\e[32m#{$1}\e[0m" }.
gsub(/((?:^[ \t]+.+(?:\n+|\Z))+)/) { CodeRay.scan($1, :ruby).term }.
gsub(/`(?:\s*\n)?([^\e]*?)\s*`/) { "`#{CodeRay.scan($1, :ruby).term}`" }

View file

@ -56,6 +56,10 @@ describe Pry::Helpers::DocumentationHelpers do
expect(@helper.process_rdoc("for <code>Example</code>")).to match(/for \e.*Example\e.*/)
end
it "should syntax highlight code in <tt>" do
expect(@helper.process_rdoc("for <tt>Example</tt>")).to match(/for \e.*Example\e.*/)
end
it "should not double-highlight backticks inside indented code" do
expect(@helper.process_rdoc(" `echo 5`")).to match(/echo 5/)
end