vendor/bundle/ruby/2.1.0/gems/org-ruby-0.9.12/lib/org-ruby/regexp_helper.rb
def rewrite_emphasis str
      # escape the percent signs for safe restoring code snippets
      str.gsub!(/%/, "%%")
      format_str = "%s"
      str.gsub! @org_emphasis_regexp do |match|
        pre = $1
        # preserve the code snippet from further formatting
        if $2 == "=" or $2 == "~"
          inner = yield $2, $3
          # code is not formatted, so turn to single percent signs
          inner.gsub!(/%%/, "%")
          @code_snippet_stack.push inner
          "#{pre}#{format_str}"
        else
          inner = yield $2, $3
          "#{pre}#{inner}"
        end
      end
    end
# Compute replacements for all matching emphasized phrases.
# Supply a block that will get the marker and body as parameters;
# return the replacement string from your block.
#
# = Example
#
#   re = RegexpHelper.new
#   result = re.rewrite_emphasis("*bold*, /italic/, =code=") do |marker, body|
#       "<#{map[marker]}>#{body}</#{map[marker]}>"
#   end
#
# In this example, the block body will get called three times:
#
# 1. Marker: "*", body: "bold"
# 2. Marker: "/", body: "italic"
# 3. Marker: "=", body: "code"
#
# The return from this block is a string that will be used to
# replace "*bold*", "/italic/", and "=code=",
# respectively. (Clearly this sample string will use HTML-like
# syntax, assuming +map+ is defined appropriately.)
Compute replacements for all matching emphasized phrases.
Supply a block that will get the marker and body as parameters;
return the replacement string from your block.

Example



In this example, the block body will get called three times.

1.


Compute replacements for all matching emphasized phrases . Supply a block that will get the marker and body as parameters ; return the replacement string from your block . Example In this example the block body will get called three times . 1 .
def rewrite_emphasis str
      str.gsub!(/%/, "%%")
      format_str = "%s"
      str.gsub! @org_emphasis_regexp do |match|
        pre = $1
        if $2 == "=" or $2 == "~"
          inner = yield $2, $3
          inner.gsub!(/%%/, "%")
          @code_snippet_stack.push inner
          "#{pre}#{format_str}"
        else
          inner = yield $2, $3
          "#{pre}#{inner}"
        end
      end
    end
def rewrite_emphasis str str . gsub! ( / % / , "%%" ) format_str = "%s" str . gsub! @org_emphasis_regexp do | match | pre = $1 if $2 == "=" or $2 == "~" inner = yield $2 , $3 inner . gsub! ( / %% / , "%" ) @code_snippet_stack . push inner "#{pre}#{format_str}" else inner = yield $2 , $3 "#{pre}#{inner}" end end end
Compute replacements for all matching emphasized phrases.
Compute replacements for all matching emphasized phrases .
# escape the percent signs for safe restoring code snippets # preserve the code snippet from further formatting # code is not formatted, so turn to single percent signs
str