diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9688ab113..28f2213e3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -404,7 +404,6 @@ Layout/SpaceInsideStringInterpolation: - 'app/models/issue_query.rb' - 'app/models/mail_handler.rb' - 'lib/redmine/core_ext/string/inflections.rb' - - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' - 'test/integration/admin_test.rb' Lint/AmbiguousBlockAssociation: diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index d68c3a264..52ade2290 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -255,7 +255,7 @@ class RedCloth3 < String # #=>"
#{ code }#{ after }", false )
+ lang = " lang=\"#{lang}\"" if lang
+ rip_offtags( +"#{before}#{code}#{after}", false )
end
end
@@ -680,13 +680,13 @@ class RedCloth3 < String
end
if block_applied.zero?
if deep_code
- blk = "\t#{ blk }"
+ blk = "\t#{blk}"
else
- blk = "\t#{ blk }
" + blk = "\t#{blk}
" end end # hard_break blk - blk + "\n#{ code_blk }" + blk + "\n#{code_blk}" end end end.join( "\n\n" ) ) @@ -694,14 +694,14 @@ class RedCloth3 < String def textile_bq( tag, atts, cite, content ) cite, cite_title = check_refs( cite ) - cite = " cite=\"#{ cite }\"" if cite + cite = " cite=\"#{cite}\"" if cite atts = shelve( atts ) if atts - "\t\n\t\t" + "\t#{ content }
\n\t
\n\t\t" end def textile_p( tag, atts, cite, content ) atts = shelve( atts ) if atts - "\t<#{ tag }#{ atts }>#{ content }#{ tag }>" + "\t<#{tag}#{atts}>#{content}#{tag}>" end alias textile_h1 textile_p @@ -712,10 +712,10 @@ class RedCloth3 < String alias textile_h6 textile_p def textile_fn_( tag, num, atts, cite, content ) - atts << " id=\"fn#{ num }\" class=\"footnote\"" - content = "#{ num } #{ content }" + atts << " id=\"fn#{num}\" class=\"footnote\"" + content = "#{num} #{content}" atts = shelve( atts ) if atts - "\t#{content}
\n\t
#{ content }
" + "\t#{content}
" end BLOCK_RE = /^(([a-z]+)(\d*))(#{A}#{C})\.(?::(\S+))? (.*)$/m @@ -727,10 +727,10 @@ class RedCloth3 < String # pass to prefix handler replacement = nil - if respond_to? "textile_#{ tag }", true - replacement = method( "textile_#{ tag }" ).call( tag, atts, cite, content ) - elsif respond_to? "textile_#{ tagpre }_", true - replacement = method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) + if respond_to? "textile_#{tag}", true + replacement = method( "textile_#{tag}" ).call( tag, atts, cite, content ) + elsif respond_to? "textile_#{tagpre}_", true + replacement = method( "textile_#{tagpre}_" ).call( tagpre, num, atts, cite, content ) end text.gsub!( $& ) { replacement } if replacement end @@ -740,7 +740,7 @@ class RedCloth3 < String def block_markdown_setext( text ) if text =~ SETEXT_RE tag = ($2 == "=" ? "h1" : "h2") - blk, cont = "<#{ tag }>#{ $1 }#{ tag }>", $' + blk, cont = "<#{tag}>#{$1}#{tag}>", $' blocks cont text.replace( blk + cont ) end @@ -754,8 +754,8 @@ class RedCloth3 < String $/x def block_markdown_atx( text ) if text =~ ATX_RE - tag = "h#{ $1.length }" - blk, cont = "<#{ tag }>#{ $2 }#{ tag }>\n\n", $' + tag = "h#{$1.length}" + blk, cont = "<#{tag}>#{$2}#{tag}>\n\n", $' blocks cont text.replace( blk + cont ) end @@ -769,7 +769,7 @@ class RedCloth3 < String flush_left blk blocks blk blk.gsub!( /^(\S)/, "\t\\1" ) - "\n#{ blk }\n\n\n" + "
\n#{blk}\n\n\n" end end @@ -804,7 +804,7 @@ class RedCloth3 < String atts = pba( atts ) atts = shelve( atts ) if atts - "#{ sta }#{ oqs }<#{ ht }#{ atts }>#{ content }#{ ht }>#{ oqa }" + "#{sta}#{oqs}<#{ht}#{atts}>#{content}#{ht}>#{oqa}" end end end @@ -844,13 +844,13 @@ class RedCloth3 < String post = ")"+post # add closing parenth to post end atts = pba( atts ) - atts = +" href=\"#{ htmlesc url }#{ slash }\"#{ atts }" - atts << " title=\"#{ htmlesc title }\"" if title + atts = +" href=\"#{htmlesc url}#{slash}\"#{atts}" + atts << " title=\"#{htmlesc title}\"" if title atts = shelve( atts ) if atts external = (url =~ /^https?:\/\//) ? ' class="external"' : '' - "#{ pre }#{ text }#{ post }" + "#{pre}#{text}#{post}" end end end @@ -872,11 +872,11 @@ class RedCloth3 < String url, title = check_refs( id ) end - atts = " href=\"#{ url }\"" - atts << " title=\"#{ title }\"" if title + atts = " href=\"#{url}\"" + atts << " title=\"#{title}\"" if title atts = shelve( atts ) - "#{ text }" + "#{text}" end end @@ -898,11 +898,11 @@ class RedCloth3 < String text.gsub!( MARKDOWN_LINK_RE ) do |m| text, url, quote, title = $~[1..4] - atts = " href=\"#{ url }\"" - atts << " title=\"#{ title }\"" if title + atts = " href=\"#{url}\"" + atts << " title=\"#{title}\"" if title atts = shelve( atts ) - "#{ text }" + "#{text}" end end @@ -947,7 +947,7 @@ class RedCloth3 < String \s? # optional space (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title \! # closing - (?::#{ HYPERLINK })? # optional href + (?::#{HYPERLINK})? # optional href /x def inline_textile_image( text ) @@ -955,9 +955,9 @@ class RedCloth3 < String stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8] htmlesc title atts = pba( atts ) - atts = +" src=\"#{ htmlesc url.dup }\"#{ atts }" - atts << " title=\"#{ title }\"" if title - atts << " alt=\"#{ title }\"" + atts = +" src=\"#{htmlesc url.dup}\"#{atts}" + atts << " title=\"#{title}\"" if title + atts << " alt=\"#{title}\"" # size = @getimagesize($url); # if($size) $atts.= " $size[3]"; @@ -967,16 +967,16 @@ class RedCloth3 < String next m unless uri_with_safe_scheme?(url) out = +'' - out << "" if href - out << "
" - out = "
#{ out }" + out = "
#{out}"
else
- out = "#{ stln }#{ out }"
+ out = "#{stln}#{out}"
end
else
out = stln + out
@@ -988,7 +988,7 @@ class RedCloth3 < String
def shelve( val )
@shelf << val
- " :redsh##{ @shelf.length }:"
+ " :redsh##{@shelf.length}:"
end
def retrieve( text )
@@ -1044,9 +1044,9 @@ class RedCloth3 < String
end
OFFTAGS = /(code|pre|kbd|notextile)/
- OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }\b>)|(<#{ OFFTAGS }\b[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\b\W|\Z)/mi
- OFFTAG_OPEN = /<#{ OFFTAGS }/
- OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/
+ OFFTAG_MATCH = /(?:(<\/#{OFFTAGS}\b>)|(<#{OFFTAGS}\b[^>]*>))(.*?)(?=<\/?#{OFFTAGS}\b\W|\Z)/mi
+ OFFTAG_OPEN = /<#{OFFTAGS}/
+ OFFTAG_CLOSE = /<\/?#{OFFTAGS}/
HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m
ALLTAG_MATCH = /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m
@@ -1096,12 +1096,12 @@ class RedCloth3 < String
### NB: some changes were made not to use $N variables, because we use "match"
### and it breaks following lines
htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag && !first.match(//)
- line = +"