diff options
author | Go MAEDA <maeda@farend.jp> | 2019-06-06 14:50:14 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-06-06 14:50:14 +0000 |
commit | 9eafc3e9a2dad4de36d64bd26d2e9f18c2943b98 (patch) | |
tree | 0e1351d51bbb2e4e688bcc6d12d97fb672a0d09d /lib/redmine | |
parent | 2e0ec5b0e66d288a476d79b2163a316dbbed0f8c (diff) | |
download | redmine-9eafc3e9a2dad4de36d64bd26d2e9f18c2943b98.tar.gz redmine-9eafc3e9a2dad4de36d64bd26d2e9f18c2943b98.zip |
Remove trailing whitespaces from lib (#31506).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@18231 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r-- | lib/redmine/helpers/time_report.rb | 6 | ||||
-rw-r--r-- | lib/redmine/helpers/url.rb | 2 | ||||
-rw-r--r-- | lib/redmine/hook/view_listener.rb | 4 | ||||
-rw-r--r-- | lib/redmine/nested_set/issue_nested_set.rb | 8 | ||||
-rw-r--r-- | lib/redmine/plugin.rb | 2 | ||||
-rw-r--r-- | lib/redmine/safe_attributes.rb | 2 | ||||
-rw-r--r-- | lib/redmine/scm/adapters/bazaar_adapter.rb | 4 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting/html_parser.rb | 6 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting/macros.rb | 8 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting/textile/redcloth3.rb | 176 |
10 files changed, 109 insertions, 109 deletions
diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb index 33a32f887..eb6abed04 100644 --- a/lib/redmine/helpers/time_report.rb +++ b/lib/redmine/helpers/time_report.rb @@ -58,7 +58,7 @@ module Redmine end @hours << h end - + @hours.each do |row| case @columns when 'year' @@ -71,13 +71,13 @@ module Redmine row['day'] = "#{row['spent_on']}" end end - + min = @hours.collect {|row| row['spent_on']}.min @from = min ? min.to_date : User.current.today max = @hours.collect {|row| row['spent_on']}.max @to = max ? max.to_date : User.current.today - + @total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f} @periods = [] diff --git a/lib/redmine/helpers/url.rb b/lib/redmine/helpers/url.rb index 6e6246d93..f5b44555f 100644 --- a/lib/redmine/helpers/url.rb +++ b/lib/redmine/helpers/url.rb @@ -26,7 +26,7 @@ module Redmine # URLs relative to the current document or document root (without a protocol # separator, should be harmless return true unless uri.to_s.include? ":" - + # Other URLs need to be parsed schemes.include? URI.parse(uri).scheme rescue URI::Error diff --git a/lib/redmine/hook/view_listener.rb b/lib/redmine/hook/view_listener.rb index 1e69d0755..411658dd7 100644 --- a/lib/redmine/hook/view_listener.rb +++ b/lib/redmine/hook/view_listener.rb @@ -67,11 +67,11 @@ module Redmine end end end - + def controller nil end - + def config ActionController::Base.config end diff --git a/lib/redmine/nested_set/issue_nested_set.rb b/lib/redmine/nested_set/issue_nested_set.rb index 2c34cac96..1f62bc072 100644 --- a/lib/redmine/nested_set/issue_nested_set.rb +++ b/lib/redmine/nested_set/issue_nested_set.rb @@ -86,19 +86,19 @@ module Redmine if parent previous_root_id = root_id self.root_id = parent.root_id - + lft_after_move = target_lft self.class.where(:root_id => parent.root_id).update_all([ "lft = CASE WHEN lft >= :lft THEN lft + :shift ELSE lft END, " + "rgt = CASE WHEN rgt >= :lft THEN rgt + :shift ELSE rgt END", {:lft => lft_after_move, :shift => (rgt - lft + 1)} ]) - + self.class.where(:root_id => previous_root_id).update_all([ "root_id = :root_id, lft = lft + :shift, rgt = rgt + :shift", {:root_id => parent.root_id, :shift => lft_after_move - lft} ]) - + self.lft, self.rgt = lft_after_move, (rgt - lft + lft_after_move) parent.send :reload_nested_set_values end @@ -107,7 +107,7 @@ module Redmine def remove_from_nested_set self.class.where(:root_id => root_id).where("lft >= ? AND rgt <= ?", lft, rgt). update_all(["root_id = :id, lft = lft - :shift, rgt = rgt - :shift", {:id => id, :shift => lft - 1}]) - + self.class.where(:root_id => root_id).update_all([ "lft = CASE WHEN lft >= :lft THEN lft - :shift ELSE lft END, " + "rgt = CASE WHEN rgt >= :lft THEN rgt - :shift ELSE rgt END", diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index 4780dece0..b3982fcfd 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -398,7 +398,7 @@ module Redmine # * :label - label for the formatter displayed in application settings # # Examples: - # wiki_format_provider(:custom_formatter, CustomFormatter, :label => "My custom formatter") + # wiki_format_provider(:custom_formatter, CustomFormatter, :label => "My custom formatter") # def wiki_format_provider(name, *args) Redmine::WikiFormatting.register(name, *args) diff --git a/lib/redmine/safe_attributes.rb b/lib/redmine/safe_attributes.rb index 52c2df096..a08e63f7e 100644 --- a/lib/redmine/safe_attributes.rb +++ b/lib/redmine/safe_attributes.rb @@ -34,7 +34,7 @@ module Redmine @safe_attributes ||= [] if args.empty? if superclass.include?(Redmine::SafeAttributes) - @safe_attributes + superclass.safe_attributes + @safe_attributes + superclass.safe_attributes else @safe_attributes end diff --git a/lib/redmine/scm/adapters/bazaar_adapter.rb b/lib/redmine/scm/adapters/bazaar_adapter.rb index a901bfb54..c342d13ff 100644 --- a/lib/redmine/scm/adapters/bazaar_adapter.rb +++ b/lib/redmine/scm/adapters/bazaar_adapter.rb @@ -294,7 +294,7 @@ module Redmine full_args_locale << scm_iconv(@path_encoding, 'UTF-8', e) end ret = shellout( - self.class.sq_bin + ' ' + + self.class.sq_bin + ' ' + full_args_locale.map { |e| shell_quote e.to_s }.join(' '), &block ) @@ -313,7 +313,7 @@ module Redmine full_args_locale << scm_iconv(@path_encoding, 'UTF-8', e) end ret = shellout( - self.class.sq_bin + ' ' + + self.class.sq_bin + ' ' + full_args_locale.map { |e| shell_quote e.to_s }.join(' '), &block ) diff --git a/lib/redmine/wiki_formatting/html_parser.rb b/lib/redmine/wiki_formatting/html_parser.rb index be01ca339..aa4891ce0 100644 --- a/lib/redmine/wiki_formatting/html_parser.rb +++ b/lib/redmine/wiki_formatting/html_parser.rb @@ -31,11 +31,11 @@ module Redmine def self.to_text(html) html = html.gsub(/[\n\r]/, '').squeeze(' ') - + doc = Loofah.document(html) doc.scrub!(WikiTags.new(tags)) doc.scrub!(:newline_block_elements) - + Loofah.remove_extraneous_whitespace(doc.text).strip end @@ -44,7 +44,7 @@ module Redmine @direction = :bottom_up @tags_to_text = tags_to_text || {} end - + def scrub(node) formatting = @tags_to_text[node.name] case formatting diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index 0cc55e281..8afa0f8e7 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -69,7 +69,7 @@ module Redmine # macro :my_macro do |obj, args| # "My macro output" # end - # + # # desc "This is my macro that accepts a block of text" # macro :my_macro do |obj, args, text| # "My macro output" @@ -83,7 +83,7 @@ module Redmine # # Options: # * :desc - A description of the macro - # * :parse_args => false - Disables arguments parsing (the whole arguments + # * :parse_args => false - Disables arguments parsing (the whole arguments # string is passed to the macro) # # Macro blocks accept 2 or 3 arguments: @@ -91,7 +91,7 @@ module Redmine # * args: macro arguments # * text: the block of text given to the macro (should be present only if the # macro accepts a block of text). text is a String or nil if the macro is - # invoked without a block of text. + # invoked without a block of text. # # Examples: # By default, when the macro is invoked, the comma separated list of arguments @@ -164,7 +164,7 @@ module Redmine # Builtin macros desc "Sample macro." macro :hello_world do |obj, args, text| - h("Hello world! Object: #{obj.class.name}, " + + h("Hello world! Object: #{obj.class.name}, " + (args.empty? ? "Called with no argument" : "Arguments: #{args.join(', ')}") + " and " + (text.present? ? "a #{text.size} bytes long block of text." : "no block of text.") ) diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index c4dc4c25e..5a8c15142 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -73,33 +73,33 @@ # # == Links # -# To make a hypertext link, put the link text in "quotation +# To make a hypertext link, put the link text in "quotation # marks" followed immediately by a colon and the URL of the link. -# -# Optional: text in (parentheses) following the link text, -# but before the closing quotation mark, will become a Title +# +# Optional: text in (parentheses) following the link text, +# but before the closing quotation mark, will become a Title # attribute for the link, visible as a tool tip when a cursor is above it. -# +# # Example: # # "This is a link (This is a title) ":http://www.textism.com -# +# # Will become: -# +# # <a href="http://www.textism.com" title="This is a title">This is a link</a> # # == Images # # To insert an image, put the URL for the image inside exclamation marks. # -# Optional: text that immediately follows the URL in (parentheses) will -# be used as the Alt text for the image. Images on the web should always -# have descriptive Alt text for the benefit of readers using non-graphical +# Optional: text that immediately follows the URL in (parentheses) will +# be used as the Alt text for the image. Images on the web should always +# have descriptive Alt text for the benefit of readers using non-graphical # browsers. # -# Optional: place a colon followed by a URL immediately after the +# Optional: place a colon followed by a URL immediately after the # closing ! to make the image into a link. -# +# # Example: # # !http://www.textism.com/common/textist.gif(Textist)! @@ -118,13 +118,13 @@ # # == Defining Acronyms # -# HTML allows authors to define acronyms via the tag. The definition appears as a -# tool tip when a cursor hovers over the acronym. A crucial aid to clear writing, +# HTML allows authors to define acronyms via the tag. The definition appears as a +# tool tip when a cursor hovers over the acronym. A crucial aid to clear writing, # this should be used at least once for each acronym in documents where they appear. # -# To quickly define an acronym in Textile, place the full text in (parentheses) +# To quickly define an acronym in Textile, place the full text in (parentheses) # immediately following the acronym. -# +# # Example: # # ACLU(American Civil Liberties Union) @@ -147,7 +147,7 @@ # (background:#ddd;color:red). |{}| | | | # # == Using RedCloth -# +# # RedCloth is simply an extension of the String class, which can handle # Textile formatting. Use it like a String and output HTML with its # RedCloth#to_html method. @@ -270,14 +270,14 @@ class RedCloth3 < String rules = DEFAULT_RULES if rules.empty? # make our working copy text = self.dup - + @urlrefs = {} @shelf = [] textile_rules = [:block_textile_table, :block_textile_lists, :block_textile_prefix, :inline_textile_image, :inline_textile_code, :inline_textile_span, :inline_textile_link, :glyphs_textile] markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule, - :block_markdown_bq, :block_markdown_lists, + :block_markdown_bq, :block_markdown_lists, :inline_markdown_reflink, :inline_markdown_link] @rules = rules.collect do |rule| case rule @@ -291,8 +291,8 @@ class RedCloth3 < String end.flatten # standard clean up - incoming_entities text - clean_white_space text + incoming_entities text + clean_white_space text # start processor @pre_list = [] @@ -301,7 +301,7 @@ class RedCloth3 < String escape_html_tags text # need to do this before #hard_break and #blocks block_textile_quotes text unless @lite_mode - hard_break text + hard_break text unless @lite_mode refs text blocks text @@ -328,10 +328,10 @@ class RedCloth3 < String # TEXTILE_TAGS = - [[128, 8364], [129, 0], [130, 8218], [131, 402], [132, 8222], [133, 8230], - [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], - [140, 338], [141, 0], [142, 0], [143, 0], [144, 0], [145, 8216], [146, 8217], - [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], + [[128, 8364], [129, 0], [130, 8218], [131, 402], [132, 8222], [133, 8230], + [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], + [140, 338], [141, 0], [142, 0], [143, 0], [144, 0], [145, 8216], [146, 8217], + [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], [153, 8482], [154, 353], [155, 8250], [156, 339], [157, 0], [158, 0], [159, 376]]. collect! do |a, b| @@ -359,7 +359,7 @@ class RedCloth3 < String # Text markup tags, don't conflict with block tags SIMPLE_HTML_TAGS = [ - 'tt', 'b', 'i', 'big', 'small', 'em', 'strong', 'dfn', 'code', + 'tt', 'b', 'i', 'big', 'small', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'a', 'img', 'br', 'br', 'map', 'q', 'sub', 'sup', 'span', 'bdo' ] @@ -375,9 +375,9 @@ class RedCloth3 < String ['+', 'ins', :limit], ['^', 'sup', :limit], ['~', 'sub', :limit] - ] + ] QTAGS_JOIN = QTAGS.map {|rc, ht, rtype| Regexp::quote rc}.join('|') - + QTAGS.collect! do |rc, ht, rtype| rcq = Regexp::quote rc re = @@ -397,7 +397,7 @@ class RedCloth3 < String (#{C}) (?::(\S+))? ([[:word:]]|[^\s\-].*?[^\s\-]) - #{rcq}/xm + #{rcq}/xm end [rc, ht, re, rtype] end @@ -466,7 +466,7 @@ class RedCloth3 < String # Parses Textile attribute lists and builds an HTML attribute string def pba( text_in, element = "" ) - + return +'' unless text_in style = [] @@ -487,7 +487,7 @@ class RedCloth3 < String cls = $1 if text.sub!( /\(([^()]+?)\)/, '' ) - + style << "padding-left:#{ $1.length }em;" if text.sub!( /([(]+)/, '' ) @@ -512,7 +512,7 @@ class RedCloth3 < String atts << " id=\"#{ id }\"" if id atts << " colspan=\"#{ colspan }\"" if colspan atts << " rowspan=\"#{ rowspan }\"" if rowspan - + atts end @@ -527,9 +527,9 @@ class RedCloth3 < String end TABLE_RE = /^(?:table(_?#{S}#{A}#{C})\. ?\n)?^(#{A}#{C}\.? ?\|.*?\|)(\n\n|\Z)/m - + # Parses a Textile table block, building HTML from the result. - def block_textile_table( text ) + def block_textile_table( text ) text.gsub!( TABLE_RE ) do |matches| tatts, fullrow = $~[1..2] @@ -540,7 +540,7 @@ class RedCloth3 < String fullrow.each_line do |row| ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m cells = [] - # the regexp prevents wiki links with a | from being cut as cells + # the regexp prevents wiki links with a | from being cut as cells row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/) do |modifiers, cell| ctyp = 'd' ctyp = 'h' if modifiers && modifiers =~ /^_/ @@ -549,7 +549,7 @@ class RedCloth3 < String catts = pba( modifiers, 'td' ) if modifiers catts = shelve( catts ) if catts - cells << "\t\t\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>" + cells << "\t\t\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>" end ratts = shelve( ratts ) if ratts rows << "\t\t<tr#{ ratts }>\n#{ cells.join( "\n" ) }\n\t\t</tr>" @@ -562,13 +562,13 @@ class RedCloth3 < String LISTS_CONTENT_RE = /^([#*]+)(#{A}#{C}) (.*)$/m # Parses Textile lists and generates HTML - def block_textile_lists( text ) + def block_textile_lists( text ) text.gsub!( LISTS_RE ) do |match| lines = match.split( /\n/ ) last_line = -1 depth = [] lines.each_with_index do |line, line_id| - if line =~ LISTS_CONTENT_RE + if line =~ LISTS_CONTENT_RE tl,atts,content = $~[1..3] if depth.last if depth.last.length > tl.length @@ -604,17 +604,17 @@ class RedCloth3 < String lines.join( "\n" ) end end - + QUOTES_RE = /(^>+([^\n]*?)(\n|$))+/m QUOTES_CONTENT_RE = /^([> ]+)(.*)$/m - + def block_textile_quotes( text ) text.gsub!( QUOTES_RE ) do |match| lines = match.split( /\n/ ) quotes = +'' indent = 0 lines.each do |line| - line =~ QUOTES_CONTENT_RE + line =~ QUOTES_CONTENT_RE bq,content = $1, $2 l = bq.count('>') if l != indent @@ -635,7 +635,7 @@ class RedCloth3 < String @ (?=\W)/x - def inline_textile_code( text ) + def inline_textile_code( text ) text.gsub!( CODE_RE ) do |m| before,lang,code,after = $~[1..4] lang = " lang=\"#{ lang }\"" if lang @@ -643,7 +643,7 @@ class RedCloth3 < String end end - def lT( text ) + def lT( text ) text =~ /\#$/ ? 'o' : 'u' end @@ -678,7 +678,7 @@ class RedCloth3 < String end end - block_applied = 0 + block_applied = 0 @rules.each do |rule_name| block_applied += 1 if ( rule_name.to_s.match /^block_/ and method( rule_name ).call( blk ) ) end @@ -725,7 +725,7 @@ class RedCloth3 < String BLOCK_RE = /^(([a-z]+)(\d*))(#{A}#{C})\.(?::(\S+))? (.*)$/m - def block_textile_prefix( text ) + def block_textile_prefix( text ) if text =~ BLOCK_RE tag,tagpre,num,atts,cite,content = $~[1..6] atts = pba( atts ) @@ -735,12 +735,12 @@ class RedCloth3 < String 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 ) + replacement = method( "textile_#{ tagpre }_" ).call( tagpre, num, atts, cite, content ) end text.gsub!( $& ) { replacement } if replacement end end - + SETEXT_RE = /\A(.+?)\n([=-])[=-]* *$/m def block_markdown_setext( text ) if text =~ SETEXT_RE @@ -792,10 +792,10 @@ class RedCloth3 < String def block_markdown_lists( text ) end - def inline_textile_span( text ) + def inline_textile_span( text ) QTAGS.each do |qtag_rc, ht, qtag_re, rtype| text.gsub!( qtag_re ) do |m| - + case rtype when :limit sta,oqs,qtag,content,oqa = $~[1..6] @@ -828,14 +828,14 @@ class RedCloth3 < String ( # $url (\/|[a-zA-Z]+:\/\/|www\.|mailto:) # $proto [[:alnum:]_\/]\S+? - ) + ) (\/)? # $slash ([^[:alnum:]_\=\/;\(\)\-]*?) # $post ) (?=<|\s|$) - /x + /x #" - def inline_textile_link( text ) + def inline_textile_link( text ) text.gsub!( LINK_RE ) do |m| all,pre,atts,text,title,url,proto,slash,post = $~[1..9] if text.include?('<br />') @@ -843,7 +843,7 @@ class RedCloth3 < String else url, url_title = check_refs( url ) title ||= url_title - + # Idea below : an URL with unbalanced parethesis and # ending by ')' is put into external parenthesis if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) ) @@ -854,9 +854,9 @@ class RedCloth3 < String atts = +" href=\"#{ htmlesc url }#{ slash }\"#{ atts }" atts << " title=\"#{ htmlesc title }\"" if title atts = shelve( atts ) if atts - + external = (url =~ /^https?:\/\//) ? ' class="external"' : '' - + "#{ pre }<a#{ atts }#{ external }>#{ text }</a>#{ post }" end end @@ -867,9 +867,9 @@ class RedCloth3 < String [ ]? # opt. space (?:\n[ ]*)? # one optional newline followed by spaces \[(.*?)\] # $id - /x + /x - def inline_markdown_reflink( text ) + def inline_markdown_reflink( text ) text.gsub!( MARKDOWN_REFLINK_RE ) do |m| text, id = $~[1..2] @@ -878,11 +878,11 @@ class RedCloth3 < String else url, title = check_refs( id ) end - + atts = " href=\"#{ url }\"" atts << " title=\"#{ title }\"" if title atts = shelve( atts ) - + "<a#{ atts }>#{ text }</a>" end end @@ -899,16 +899,16 @@ class RedCloth3 < String \3 # matching quote )? # title is optional \) - /x + /x - def inline_markdown_link( text ) + def inline_markdown_link( text ) text.gsub!( MARKDOWN_LINK_RE ) do |m| text, url, quote, title = $~[1..4] atts = " href=\"#{ url }\"" atts << " title=\"#{ title }\"" if title atts = shelve( atts ) - + "<a#{ atts }>#{ text }</a>" end end @@ -922,14 +922,14 @@ class RedCloth3 < String end end - def refs_textile( text ) + def refs_textile( text ) text.gsub!( TEXTILE_REFS_RE ) do |m| flag, url = $~[2..3] @urlrefs[flag.downcase] = [url, nil] nil end end - + def refs_markdown( text ) text.gsub!( MARKDOWN_REFS_RE ) do |m| flag, url = $~[2..3] @@ -939,7 +939,7 @@ class RedCloth3 < String end end - def check_refs( text ) + def check_refs( text ) ret = @urlrefs[text.downcase] if text ret || [text, nil] end @@ -955,16 +955,16 @@ class RedCloth3 < String (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title \! # closing (?::#{ HYPERLINK })? # optional href - /x + /x - def inline_textile_image( text ) + def inline_textile_image( text ) text.gsub!( IMAGE_RE ) do |m| 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 << " alt=\"#{ title }\"" # size = @getimagesize($url); # if($size) $atts.= " $size[3]"; @@ -977,8 +977,8 @@ class RedCloth3 < String out << "<a#{ shelve( " href=\"#{ href }\"" ) }>" if href out << "<img#{ shelve( atts ) } />" out << "</a>#{ href_a1 }#{ href_a2 }" if href - - if algn + + if algn algn = h_align( algn ) if stln == "<p>" out = "<p style=\"float:#{ algn }\">#{ out }" @@ -993,18 +993,18 @@ class RedCloth3 < String end end - def shelve( val ) + def shelve( val ) @shelf << val " :redsh##{ @shelf.length }:" end - - def retrieve( text ) + + def retrieve( text ) text.gsub!(/ :redsh#(\d+):/) do @shelf[$1.to_i - 1] || $& end end - def incoming_entities( text ) + def incoming_entities( 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 @@ -1012,14 +1012,14 @@ class RedCloth3 < String text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" ) end - def no_textile( text ) + def no_textile( text ) text.gsub!( /(^|\s)==([^=]+.*?)==(\s|$)?/, '\1<notextile>\2</notextile>\3' ) text.gsub!( /^ *==([^=]+.*?)==/m, '\1<notextile>\2</notextile>\3' ) end - def clean_white_space( text ) + def clean_white_space( text ) # normalize line breaks text.gsub!( /\r\n/, "\n" ) text.gsub!( /\r/, "\n" ) @@ -1045,11 +1045,11 @@ class RedCloth3 < String end end - def footnote_ref( text ) + def footnote_ref( text ) text.gsub!( /\b\[([0-9]+?)\](\s)?/, '<sup><a href="#fn\1">\1</a></sup>\2' ) end - + OFFTAGS = /(code|pre|kbd|notextile)/ OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }\b>)|(<#{ OFFTAGS }\b[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\b\W|\Z)/mi OFFTAG_OPEN = /<#{ OFFTAGS }/ @@ -1071,7 +1071,7 @@ class RedCloth3 < String elsif line =~ OFFTAG_CLOSE codepre -= 1 codepre = 0 if codepre < 0 - end + end elsif codepre.zero? glyphs_textile( line, level + 1 ) else @@ -1118,7 +1118,7 @@ class RedCloth3 < String end codepre -= 1 unless codepre.zero? used_offtags = {} if codepre.zero? - end + end line end end @@ -1132,7 +1132,7 @@ class RedCloth3 < String end end - def inline( text ) + def inline( text ) [/^inline_/, /^glyphs_/].each do |meth_re| @rules.each do |rule_name| method( rule_name ).call( text ) if rule_name.to_s.match( meth_re ) @@ -1140,11 +1140,11 @@ class RedCloth3 < String end end - def h_align( text ) + def h_align( text ) H_ALGN_VALS[text] end - def v_align( text ) + def v_align( text ) V_ALGN_VALS[text] end @@ -1158,7 +1158,7 @@ class RedCloth3 < String 'img' => ['src', 'alt', 'title'], 'br' => [], 'i' => nil, - 'u' => nil, + 'u' => nil, 'b' => nil, 'pre' => nil, 'kbd' => nil, @@ -1183,7 +1183,7 @@ class RedCloth3 < String 'h3' => nil, 'h4' => nil, 'h5' => nil, - 'h6' => nil, + 'h6' => nil, 'blockquote' => ['cite'] } @@ -1211,8 +1211,8 @@ class RedCloth3 < String end end end - - + + ALLOWED_TAGS = %w(redpre pre code kbd notextile) def escape_html_tags(text) text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' unless $3.blank?}" } |