[DRE-commits] [ruby-org] 183/303: Correct parsing of org-mode emphasis
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:33:54 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 ea2869d2b381ceb8e5693e7c71d31bf1ea33a479
Author: vonavi <ivvl82 at gmail.com>
Date: Sun Sep 30 12:14:40 2012 +0300
Correct parsing of org-mode emphasis
---
lib/org-ruby/regexp_helper.rb | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/org-ruby/regexp_helper.rb b/lib/org-ruby/regexp_helper.rb
index 22d1fb4..3bfc6fa 100644
--- a/lib/org-ruby/regexp_helper.rb
+++ b/lib/org-ruby/regexp_helper.rb
@@ -52,11 +52,11 @@ module Orgmode
def initialize
# Set up the emphasis regular expression.
- @pre_emphasis = " \t\\('\""
- @post_emphasis = "- \t.,:!?;'\"\\)"
+ @pre_emphasis = " \t\\('\"\\{"
+ @post_emphasis = "- \t\\.,:!\\?;'\"\\)\\}\\\\"
@border_forbidden = " \t\r\n,\"'"
@body_regexp = ".*?"
- @markers = "*/_=~+"
+ @markers = "\\*\\/_=~\\+"
@logger = Logger.new(STDERR)
@logger.level = Logger::WARN
build_org_emphasis_regexp
@@ -97,7 +97,7 @@ module Orgmode
def rewrite_emphasis(str)
str.gsub(@org_emphasis_regexp) do |match|
inner = yield $2, $3
- "#{$1}#{inner}#{$4}"
+ "#{$1}#{inner}"
end
end
@@ -161,11 +161,11 @@ module Orgmode
def build_org_emphasis_regexp
@org_emphasis_regexp = Regexp.new("([#{@pre_emphasis}]|^)\n" +
- "( [#{@markers}] )\n" +
- "( [^#{@border_forbidden}] | " +
- " [^#{@border_forbidden}]#{@body_regexp}[^#{@border_forbidden}] )\n" +
+ "( [#{@markers}] ) (?!\\2)\n" +
+ "( [^#{@border_forbidden}] | " +
+ "[^#{@border_forbidden}]#{@body_regexp}[^#{@border_forbidden}] )\n" +
"\\2\n" +
- "([#{@post_emphasis}]|$)\n", Regexp::EXTENDED)
+ "(?=[#{@post_emphasis}]|$)\n", Regexp::EXTENDED)
@logger.debug "Just created regexp: #{@org_emphasis_regexp}"
end
--
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