Class Texy::HtmlParser
In: lib/texy/parser.rb
Parent: Parser

Internal html parsing structure

Methods

parse  

Constants

PATTERN = /<(\/?)([a-z][a-z0-9_:-]*)(|\s(?:[\sa-z0-9:-]|=\s*"[^"#{HASH}]*"|=\s*'[^\'#{HASH}]*'|=[^>#{HASH}]*)*)(\/?)>|<!--([^#{HASH}]*?)-->/i

Public Instance methods

[Source]

# File lib/texy/parser.rb, line 250
        def parse(text)
            # Initialization
            texy = element.texy

            # (rane) attempt to emulate php's preg_match_all...
            matches = []
            offset = 0

            while offset < text.length
                match_data = PATTERN.match(text[offset..-1])

                break unless match_data

                matches << [match_data.begin(0) + offset, match_data.to_a]
                offset += match_data.end(0)
            end

            matches.reverse.each do |match|
                text[match[0], match[1][0].length] = texy.html_module.process(self, match[1])
            end

            text = Html.html_chars(text, false, true)

            element.set_content(text, true)
            # (rane) FIXME: shouldn't there be = instead of == ?
            element.content_type == DomElement::CONTENT_BLOCK
        end

[Validate]