Show
Ignore:
Timestamp:
01/16/2007 15:23:36 (19 months ago)
Author:
jgarber
Message:

Convert tabs to spaces

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/redcloth/base.rb

    r128 r129  
    1010                      :block_markdown_bq, :block_markdown_lists,  
    1111                      :inline_markdown_reflink, :inline_markdown_link] 
    12                 DOCBOOK_RULES = [:refs_docbook, :block_docbook_table, :block_docbook_lists, :block_docbook_simple_lists, 
    13                                  :block_docbook_defs, :block_docbook_prefix, :inline_docbook_image, :inline_docbook_link, 
     12    DOCBOOK_RULES = [:refs_docbook, :block_docbook_table, :block_docbook_lists, :block_docbook_simple_lists, 
     13                     :block_docbook_defs, :block_docbook_prefix, :inline_docbook_image, :inline_docbook_link, 
    1414                     :inline_docbook_code, :inline_docbook_glyphs, :inline_docbook_span, 
    1515                     :inline_docbook_wiki_words, :inline_docbook_wiki_links, :inline_docbook_autolink_urls, 
     
    9898        text = self.dup 
    9999         
    100         return "" if text == "" 
     100        return "" if text == "" 
    101101 
    102102        @urlrefs = {} 
     
    401401    BLOCK_GROUP_SPLITTER = "XXX_BLOCK_GROUP_XXX\n\n" 
    402402    def blocks( text, deep_code = false ) 
    403                         @current_class ||= nil 
    404                          
    405                         # Find all occurences of div(class). and process them as blocks 
    406                         text.gsub!( /^div\((.*?)\)\.\s*(.*?)(?=div\([^\)]+\)\.\s*)/m ) do |blk| 
    407                                 block_class = (@current_class == $1) ? nil : %{ class=#{$1.inspect}} 
    408                                 @current_class = $1 
    409                                 BLOCK_GROUP_SPLITTER + ( ($2.strip.empty? || block_class.nil?) ? $2 : textile_p('div', block_class, nil, "\n\n#{$2.strip}\n\n") ) 
    410                         end 
    411                          
    412                         # Take care of the very last div 
    413                         text.sub!( /div\((.*?)\)\.\s*(.*)/m ) do |blk| 
    414                                 block_class = (@current_class == $1) ? nil : %{ class=#{$1.inspect}} 
    415                                 @current_class = $1 
    416                                 BLOCK_GROUP_SPLITTER + ( ($2.strip.empty? || block_class.nil?) ? $2 : textile_p('div', block_class, nil, "\n\n#{$2.strip}\n\n") ) 
    417                         end 
     403      @current_class ||= nil 
     404       
     405      # Find all occurences of div(class). and process them as blocks 
     406      text.gsub!( /^div\((.*?)\)\.\s*(.*?)(?=div\([^\)]+\)\.\s*)/m ) do |blk| 
     407        block_class = (@current_class == $1) ? nil : %{ class=#{$1.inspect}} 
     408        @current_class = $1 
     409        BLOCK_GROUP_SPLITTER + ( ($2.strip.empty? || block_class.nil?) ? $2 : textile_p('div', block_class, nil, "\n\n#{$2.strip}\n\n") ) 
     410      end 
     411       
     412      # Take care of the very last div 
     413      text.sub!( /div\((.*?)\)\.\s*(.*)/m ) do |blk| 
     414        block_class = (@current_class == $1) ? nil : %{ class=#{$1.inspect}} 
     415        @current_class = $1 
     416        BLOCK_GROUP_SPLITTER + ( ($2.strip.empty? || block_class.nil?) ? $2 : textile_p('div', block_class, nil, "\n\n#{$2.strip}\n\n") ) 
     417      end 
    418418       
    419419      # Handle the text now that the placeholders for divs are set, splitting at BLOCK_GROUP_SPLITTER 
     
    422422      end.join) 
    423423    end 
    424                  
    425                 def block_groups( text, deep_code = false ) 
    426                   text.replace text.split( BLOCKS_GROUP_RE ).collect { |blk| blk(blk, deep_code) }.join("\n") 
    427                 end 
    428  
    429                 # Surrounds blocks with paragraphs and shelves them when necessary 
    430                 def blk( text, deep_code = false ) 
    431                         return text if text =~ /<[0-9]+>/ 
    432                          
    433                   plain = text !~ /\A[#*> ]/ 
     424     
     425    def block_groups( text, deep_code = false ) 
     426      text.replace text.split( BLOCKS_GROUP_RE ).collect { |blk| blk(blk, deep_code) }.join("\n") 
     427    end 
     428 
     429    # Surrounds blocks with paragraphs and shelves them when necessary 
     430    def blk( text, deep_code = false ) 
     431      return text if text =~ /<[0-9]+>/ 
     432       
     433      plain = text !~ /\A[#*> ]/ 
    434434 
    435435      # skip blocks that are complex HTML 
     
    467467              text << "\n#{ code_blk }" 
    468468          end 
    469                                         return text 
     469          return text 
    470470      end 
    471471       
    472472    end 
    473                  
     473     
    474474    def refs( text ) 
    475475        @rules.each do |rule_name| 
     
    482482        ret || [text, nil] 
    483483    end 
    484                  
    485                 # Puts text in storage and returns is placeholder 
    486                 #  e.g. shelve("some text") => <1> 
     484     
     485    # Puts text in storage and returns is placeholder 
     486    #  e.g. shelve("some text") => <1> 
    487487    def shelve( val )  
    488488        @shelf << val 
     
    490490    end 
    491491     
    492                 # Retrieves text from storage using its placeholder 
    493                 #  e.g. retrieve("<1>") => "some text" 
     492    # Retrieves text from storage using its placeholder 
     493    #  e.g. retrieve("<1>") => "some text" 
    494494    def retrieve( text )  
    495495        @shelf.each_with_index do |r, i|