This guide examines how to parse a Ruby Heredoc object and convert any lines with a hashtag to HTML H1 headings.
Summary
Parse a Ruby Heredoc and replace any lines that start with a hashtag with HTML H1 heading tags.
Exercise File
Exercise Description
Given a Ruby Heredoc string, replace any lines that start with a hashtag and wrap them in HTML H1 heading tags.
Sample Input
content = <<-EOF # Hey there Some content # Another heading More content EOF
Expected Output
"<h1>Hey there</h1>\n\nSome content\n\n<h1>Another heading</h1>\n\nMore content\n"
Real World Usage
When it comes to working with Rails helper methods, it’s important to understand how to parse large strings and replace patterns with other strings.
Solution
Can be found on the solutions branch on github.