public Method

BlueCloth.transform_headers( str, rs )

Apply Markdown header transforms to a copy of the given str amd render state rs and return the result.

Source Code

# File bluecloth.rb, line 677
def transform_headers( str, rs )
        @log.debug " Transforming headers"

        # Setext-style headers:
        #       Header 1
        #       ========
        #  
        #       Header 2
        #       --------
        #
        str.
                gsub( SetextHeaderRegexp ) {|m|
                        @log.debug "Found setext-style header"
                        title, hdrchar = $1, $2
                        title = apply_span_transforms( title, rs )

                        case hdrchar
                        when '='
                                %[<h1>#{title}</h1>\n\n]
                        when '-'
                                %[<h2>#{title}</h2>\n\n]
                        else
                                title
                        end
                }.

                gsub( AtxHeaderRegexp ) {|m|
                        @log.debug "Found ATX-style header"
                        hdrchars, title = $1, $2
                        title = apply_span_transforms( title, rs )

                        level = hdrchars.length
                        %{<h%d>%s</h%d>\n\n} % [ level, title, level ]
                }
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.