# File lib/maruku/input/parse_doc.rb, line 190
        def substitute_markdown_inside_raw_html
                self.each_element(:raw_html) do |e|
                        doc = e.instance_variable_get :@parsed_html
                        if doc # valid html
                                # parse block-level markdown elements in these HTML tags
                                block_tags = ['div']

                                # use xpath to find elements with 'markdown' attribute
                                XPath.match(doc, "//*[attribute::markdown]" ).each do |e|
#                                       puts "Found #{e}"
                                        # should we parse block-level or span-level?
                                        
                                        how = e.attributes['markdown']
                                        parse_blocks = (how == 'block') || block_tags.include?(e.name)
                                                       
                                        # Select all text elements of e
                                        XPath.match(e, "//text()" ).each { |original_text| 
                                                s = original_text.value.strip
                                                if s.size > 0

                                        #      puts "Parsing #{s.inspect} as blocks: #{parse_blocks}  (#{e.name}, #{e.attributes['markdown']})  "

                                                        el = md_el(:dummy,
                                                                 parse_blocks ? parse_text_as_markdown(s) :
                                                                          parse_lines_as_span([s]) )
                                                        p = original_text.parent
                                                        el.children_to_html.each do |x|
                                                                p.insert_before(original_text, x)
                                                        end
                                                        p.delete(original_text)
                                                        
                                                end
                                        }
                                        
                                        
          # remove 'markdown' attribute
          e.delete_attribute 'markdown'
          
                                end
                                
                        end
                end
        end