Changeset 127

Show
Ignore:
Timestamp:
04/26/2006 23:04:48 (3 years ago)
Author:
cardmagic
Message:

Fixing a few pieces of the docbook export, like footnotes

Files:
1 modified

Legend:

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

    r126 r127  
    255255      text.gsub!( %r{<programlisting>\n}, "<programlisting>" ) 
    256256      text.gsub!( %r{\n</programlisting>}, "</programlisting>\n" ) 
    257  
     257       
     258      i = 1 
     259      text.gsub!(/\[\d+\]/) do |ref| 
     260        id = ref[/\d+/].to_i 
     261        if id == i 
     262          i += 1 
     263          if text =~ /<footnote id="fn#{id}">(.*?)<\/footnote>/ 
     264            "<footnote id=\"footnote#{id}\">#{$1}</footnote>" 
     265          else 
     266            ref 
     267          end 
     268        else 
     269          ref 
     270        end 
     271      end 
     272       
     273      text.gsub!(/<footnote id="fn\d+">(.*?)<\/footnote>/, '') 
     274       
    258275      DOCBOOK_TAGS.each do |qtag_rc, ht, qtag_re, rtype, escaped_re| 
    259276          text.gsub!( escaped_re ) do |m| 
     
    568585    def docbook_fn_( tag, num, atts, cite, content ) 
    569586        atts << " id=\"fn#{ num }\"" 
    570         content = "<superscript>#{ num }</superscript> #{ content }" 
    571587        atts = shelve( atts ) if atts 
    572         "<para>#{ content }</para>" 
     588        "<footnote#{atts}><para>#{ content }</para></footnote>" 
    573589    end 
    574590 
     
    689705    end 
    690706 
    691     def docbook_footnote_ref( text )  
    692         text.gsub!( /\b\[([0-9]+?)\](\s)?/, 
    693             '<superscript><link linkend="#fn\1">\1</link></superscript>\2' ) 
    694     end 
    695  
    696707    def inline_docbook_glyphs( text, level = 0 ) 
    697708        if text !~ HASTAG_MATCH 
    698709            docbook_pgl text 
    699             docbook_footnote_ref text 
    700710        else 
    701711            codepre = 0