diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2011-12-12 04:50:36 +0100 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2011-12-12 04:50:36 +0100 |
commit | c044a7a6eaba9ba47b8fde2cd6bdd444d8f87062 (patch) | |
tree | c47e570b5785a1bdc6c7db59a24ef10fed117340 | |
parent | c38a5e228964fa9b0b3351a197cb3f0da10c9ec4 (diff) | |
download | coderay-c044a7a6eaba9ba47b8fde2cd6bdd444d8f87062.tar.gz |
simplify multiline diff regexp
-rw-r--r-- | lib/coderay/scanners/diff.rb | 2 | ||||
-rw-r--r-- | lib/coderay/scanners/erb.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb index 18ffa39..b890ed5 100644 --- a/lib/coderay/scanners/diff.rb +++ b/lib/coderay/scanners/diff.rb @@ -102,7 +102,7 @@ module Scanners next elsif match = scan(/-/) deleted_lines_count += 1 - if options[:inline_diff] && deleted_lines_count == 1 && (changed_lines_count = 1 + check(/(?>.*(?:\n\-.*)*)/).count("\n")) && match?(/(?>.*(?:\n\-.*){#{changed_lines_count - 1}}(?:\n\+.*){#{changed_lines_count}})$(?!\n\+)/) + if options[:inline_diff] && deleted_lines_count == 1 && (changed_lines_count = 1 + check(/.*(?:\n\-.*)*/).count("\n")) && match?(/(?>.*(?:\n\-.*){#{changed_lines_count - 1}}(?:\n\+.*){#{changed_lines_count}})$(?!\n\+)/) deleted_lines = Array.new(changed_lines_count) { |i| skip(/\n\-/) if i > 0; scan(/.*/) } inserted_lines = Array.new(changed_lines_count) { |i| skip(/\n\+/) ; scan(/.*/) } diff --git a/lib/coderay/scanners/erb.rb b/lib/coderay/scanners/erb.rb index 727a993..4f39e58 100644 --- a/lib/coderay/scanners/erb.rb +++ b/lib/coderay/scanners/erb.rb @@ -41,7 +41,7 @@ module Scanners end def scan_tokens encoder, options - + # FIXME: keep_state until eos? if (match = scan_until(/(?=#{START_OF_ERB})/o) || scan_rest) and not match.empty? |