This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The goal of this problem is to extract headers from a block of text, | |
# and arrange them hierarchically. | |
# | |
# See the specs for more detail on the output | |
HEADER_HTML = /\<(h[\d])\>([^<>]+)\<\/h[\d]\>/ | |
HEADER_LEVEL_AND_CONTENT = /h(?<level>[\d])(?<content>.*)/ | |
def header_hierarchy(html) | |
html.scan(HEADER_HTML).map(&:join).map do |node| |