[DRE-commits] [ruby-org] 259/303: Fixes regexps for links and images.

Jérémy Bobbio lunar at alioth.debian.org
Fri Aug 9 17:34:09 UTC 2013


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository ruby-org.

commit 1db068229aa09c34005996d69f752f319a677994
Author: vonavi <ivvl82 at gmail.com>
Date:   Fri Feb 1 14:57:58 2013 +0200

    Fixes regexps for links and images.
---
 lib/org-ruby/regexp_helper.rb |   22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/lib/org-ruby/regexp_helper.rb b/lib/org-ruby/regexp_helper.rb
index 6214c14..12f6709 100644
--- a/lib/org-ruby/regexp_helper.rb
+++ b/lib/org-ruby/regexp_helper.rb
@@ -153,13 +153,10 @@ module Orgmode
     # +result+.
     def rewrite_links str # :yields: link, text
       str.gsub! @org_link_regexp do |match|
-        yield $1, nil
-      end
-      str.gsub! @org_link_text_regexp do |match|
-        yield $1, $2
+        yield $1, $3
       end
       str.gsub! @org_angle_link_text_regexp do |match|
-        yield "#{$2}:#{$3}", nil
+        yield $2, nil
       end
     end
 
@@ -190,17 +187,14 @@ module Orgmode
 
     def build_org_link_regexp
       @org_link_regexp = /\[\[
-                             ([^\]]*) # This is the URL
-                          \]\]/x
+                             ([^\]\[]+) # This is the URL
+                          \](\[
+                             ([^\]\[]+) # This is the friendly text
+                          \])?\]/x
       @org_img_regexp = /\[\[
-          ([^\]]*\.(jpg|jpeg|gif|png)) # Like a normal URL, but must end with a specified extension
+          ([^\]\[]+\.(jpg|jpeg|gif|png)) # Like a normal URL, but must end with a specified extension
         \]\]/xi
-      @org_link_text_regexp = /\[\[
-                                 ([^\]]*) # This is the URL
-                               \]\[
-                                 ([^\]]*) # This is the friendly text
-                               \]\]/x
-      @org_angle_link_text_regexp = /(<|<)(\w+):([^\]\t\n\r<> ][^\]\t\n\r<> ]*)(>|>)/x
+      @org_angle_link_text_regexp = /(<|<)(\w+:[^\]\s<>]+?)(>|>)/
     end
   end                           # class Emphasis
 end                             # module Orgmode

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-org.git



More information about the Pkg-ruby-extras-commits mailing list