Project

General

Profile

Feature #2985 » redcloth.diff

Jean-Baptiste Barth, 2009-03-16 17:38

View differences:

test/unit/helpers/application_helper_test.rb (working copy)
'(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>)',
'(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>).',
'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&#38;t=z&#38;s=">http://foo.bar/page?p=1&#38;t=z&#38;s=</a>',
'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>',
'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
lib/redcloth3.rb (working copy)
retrieve text
text.gsub!( /<\/?notextile>/, '' )
text.gsub!( /x%x%/, '&#38;' )
### Disabled as it just bugs in pre/code blocks!!
#text.gsub!( /x%x%/, '&#38;' )
clean_html text if filter_html
text.strip!
text
......
## turn any incoming ampersands into a dummy character for now.
## This uses a negative lookahead for alphanumerics followed by a semicolon,
## implying an incoming html entity, to be skipped
text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" )
### Disabled as it just bugs in pre/code blocks
### try: blah.map(&:test) in a code block...
#text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" )
end
def no_textile( text )
......
codepre, used_offtags = 0, {}
text.gsub!( OFFTAG_MATCH ) do |line|
if $3
offtag, aftertag = $4, $5
first, offtag, aftertag = $3, $4, $5
codepre += 1
used_offtags[offtag] = true
if codepre - used_offtags.length > 0
......
@pre_list.last << line
line = ""
else
htmlesc( aftertag, :NoQuotes ) if aftertag
### htmlesc is disabled between CODE tags which will be parsed with highlighter
### Regexp in formatter.rb is : /<code\s+class="(\w+)">\s?(.+)/m
### NB: some changes were made not to use $N variables, because we use "match"
### and it breaks following lines
htmlesc( aftertag, :NoQuotes ) if (aftertag && !first.match(/<code\s+class="(\w+)">/))
line = "<redpre##{ @pre_list.length }>"
$3.match(/<#{ OFFTAGS }([^>]*)>/)
first.match(/<#{ OFFTAGS }([^>]*)>/)
tag = $1
$2.to_s.match(/(class\=\S+)/i)
tag << " #{$1}" if $1
(2-2/4)