vendor/gems/BlueCloth-1.0.0/lib/bluecloth.rb
### Transform backticked spans into <code> spans.
Transform backticked spans into  spans.
Transform backticked spans into spans .
def transform_code_spans( str, rs )
		@log.debug " Transforming code spans"
		@scanner.string = str.dup
		unless @scanner.exist?( /`/ )
			@scanner.terminate
			@log.debug "No backticks found for code span in %p" % str
			return str
		end
		@log.debug "Transforming code spans in %p" % str
		text = ''
		until @scanner.empty?
			if pre = @scanner.scan_until( /.?(?=`)/m )
				text += pre
				@log.debug "Found backtick at %d after '...%s'" % [ @scanner.pos, text[-10, 10] ]
				opener = @scanner.scan( /`+/ )
				len = opener.length
				closer = Regexp::new( opener )
				@log.debug "Scanning for end of code span with %p" % closer
				codespan = @scanner.scan_until( closer ) or
					raise FormatError::new( @scanner.rest[0,20],
						"No %p found before end" % opener )
				@log.debug "Found close of code span at %d: %p" % [ @scanner.pos - len, codespan ]
				codespan.slice!( -len, len )
				text += "<code>%s</code>" %
					encode_code( codespan.strip, rs )
			else
				text += @scanner.rest
				@scanner.terminate
			end
		end
		return text
	end
def transform_code_spans ( str , rs ) @log . debug " Transforming code spans" @scanner . string = str . dup unless @scanner . exist? ( / ` / ) @scanner . terminate @log . debug "No backticks found for code span in %p" % str return str end @log . debug "Transforming code spans in %p" % str text = '' until @scanner . empty? if pre = @scanner . scan_until ( / .?(?=`) /m ) text += pre @log . debug "Found backtick at %d after '...%s'" % [ @scanner . pos , text [ - 10 , 10 ] ] opener = @scanner . scan ( / `+ / ) len = opener . length closer = Regexp :: new ( opener ) @log . debug "Scanning for end of code span with %p" % closer codespan = @scanner . scan_until ( closer ) or raise FormatError :: new ( @scanner . rest [ 0 , 20 ] , "No %p found before end" % opener ) @log . debug "Found close of code span at %d: %p" % [ @scanner . pos - len , codespan ] codespan . slice! ( - len , len ) text += "<code>%s</code>" % encode_code ( codespan . strip , rs ) else text += @scanner . rest @scanner . terminate end end return text end
Transform backticked spans into <code> spans.
Transform backticked spans into <code > spans .
# Set up the string scanner and just return the string unless there's at # least one backtick. # Build the transformed text anew # Scan to the end of the string # Scan up to an opening backtick # Make a pattern to find the end of the span # Scan until the end of the closing backtick sequence. Chop the # backticks off the resultant string, strip leading and trailing # whitespace, and encode any enitites contained in it. # If there's no more backticks, just append the rest of the string # and move the scan pointer to the end
str
<not_specific>
rs
<not_specific>