Решение на Пета задача от Михаил Петков

Обратно към всички решения

Към профила на Михаил Петков

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 4 успешни тест(а)
  • 53 неуспешни тест(а)

Код

class Formatter
attr_accessor :old_string, :text
def initialize(submitted_text)
@old_string = submitted_text
@text = submitted_text
end
def to_html()
p = P.new(@text)
font = Font.new(@text)
link = Link.new(@text)
list = List.new(@text)
#code = Code.new(@text)
#quote = Quote.new(@text)
#h = H.new(@text)
#specialSymbols = SpecialSymbols.new(@text)
@text.strip
end
def to_s()
@text
end
def inspect()
@old_string
end
end
class P < Formatter
def initialize(string)
@text = string
check_p()
end
def check_p()
@result = /(^[^(\<\n)](.+)(\n))/.match(@text)
code_open = "<p>"
code_close = "</p>"
while (@result != nil)
s = code_open + @result.to_s.strip + code_close
@text[@result.to_s] = s
@result = /(^[^(\<\n)](.+)(\n))/.match(@text)
end
end
end
class H < Formatter
def initialize(string)
@text = string
check_h4()
check_h3()
check_h2()
check_h1()
end
def check_h1()
@result = /\#\s.+/.match(@text)
while (@result != nil)
txt = @result.to_s[2..@result.length()-2]
@text[@result.to_s] = "<h1>" + txt + "</h1>"
@result = /\#\s.+/.match(@text)
end
end
def check_h2()
@result = /\#{2}\s.+/.match(@text)
while (@result != nil)
txt = @result.to_s[2..@result.length()-2]
@text[@result.to_s] = "<h2>" + txt + "</h2>"
@result = /\#\s.+/.match(@text)
end
end
def check_h3()
@result = /\#{3}\s.+/.match(@text)
while (@result != nil)
txt = @result.to_s[2..@result.length()-2]
@text[@result.to_s] = "<h3>" + txt + "</h3>"
@result = /\#\s.+/.match(@text)
end
end
def check_h4()
@result = /\#{4}\s.+/.match(@text)
while (@result != nil)
txt = @result.to_s[2..@result.length()-2]
@text[@result.to_s] = "<h4>" + txt + "</h4>"
@result = /\#\s.+/.match(@text)
end
end
end
class Quote < Formatter
CODE_OPEN = "<blockquote>"
CODE_CLOSE = "</blockquote>"
def initialize(string)
@text = string
check_quote()
end
def check_quote()
@result = /\B\>\s.+/.match(@text)
@open = true
while (@result != nil)
quote()
end
@text[@txt] = txt + CODE_CLOSE if @open == false
end
def quote()
@txt = @result.to_s
@txt = @txt.gsub(">", "").strip
s = ""
s += code_open if @open == true
s += @txt
@text[@result.to_s] = s
@result = /\B\>\s.+/.match(@text)
@open = false
end
end
class Code < Formatter
def initialize(string)
@text = string
check_code()
end
CODE_QUOTE_OPEN = "<pre><code>"
CODE_QUOTE_CLOSE = "</code></pre>"
def check_code()
@result = /\s{4}+.+/.match(@text)
@open = true
while (@result != nil)
replace_quote()
@open = false
end
@text[txt] = txt + CODE_QUOTE_CLOSE if @open == false
end
def replace_quote()
txt = @result.to_s.gsub(" ", "")
s = ""
s += "\n" + CODE_QUOTE_OPEN if @open == true
s += txt
@text[@result.to_s] = s
@result = /\s{4}+.+/.match(@text)
s
end
end
class Link < Formatter
def initialize(string)
@text = string
check_for_link()
end
def check_for_link()
result = /\[.+\]\(.+\)/.match(@text)
while (result != nil)
text = result.to_s[1..result.length()-3]
text["]("] = ","
link = text.split(",")
new_text = '<a href="' + link[1] + '">' + link[0] + "</a>"
@text[result.to_s] = new_text
result = /\[.+\]\(.+\)/.match(@text)
end
end
end
class List < Formatter
def initialize(string)
@text = string
check_ul()
check_ol()
end
CODE_UL_OPEN = "<ul>\n"
CODE_UL_CLOSE = "\n</ul>"
def check_ul()
@result = /\*\s.+/.match(@text)
@open = true
while (@result != nil)
s = replace_ul()
@open = false
end
@text[s] = s + CODE_UL_CLOSE if @open == false
@text
end
def replace_ul()
txt = @result.to_s[2..@result.length()-2]
s = ""
s += CODE_UL_OPEN if @open == true
s += " <li>" + txt + "</li>"
@text[@result.to_s] = s
@result = /\*\s.+/.match(@text)
s
end
def check_ol()
@result = /\d\.\s.+/.match(@text)
@open = true
while (@result != nil)
replace_ol()
@open = false
end
@text[s] = s + CODE_OL_CLOSE if @open == false
@text
end
CODE_OL_OPEN = "<ol>\n"
CODE_OL_CLOSE = "\n</ol>"
def replace_ol()
txt = @result.to_s[3..@result.length()-2]
s = ""
s += CODE_OL_OPEN if open == true
s += " <li>" + txt + "<li>"
@text[@result.to_s] = s
@result = /\d\.\s.+/.match(@text)
s
end
end
class Font < Formatter
def initialize(string)
@text = string
check_for_bold_font()
check_for_italic_font()
end
def check_for_italic_font()
result = /_.+?_/.match(@text)
while (result != nil)
text = result.to_s[1..result.length()-3]
new_text = "<em>" + text+ "</em>"
@text[result.to_s] = new_text
result = /_.+?_/.match(@text)
end
end
def check_for_bold_font()
result = /\*\*.+?\*\*/.match(@text)
while (result != nil)
text = result.to_s[2..result.length()-4]
new_text = "<strong>" + text+ "</strong>"
@text[result.to_s] = new_text
result = /\*\*.+?\*\*/.match(@text)
end
end
end
class SpecialSymbols < Formatter
def initialize(string)
@text = string
check_for_special_symbols()
end
def check_for_special_symbols()
@text.each_char do |char|
case char
when '&' then @text[char] = "&amp;"
when '<' then @text[char] = "&lt;"
when '>' then @text[char] = "&gt;"
when '"' then @text[char] = "&quot;"
end
end
end
end

Лог от изпълнението

FFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF..FFFFFFFFFFFFF.F

Failures:

  1) Formatter paragraphs renders simple paragraphs
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Simple text!</p>"
            got: "Simple text!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:6:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Formatter paragraphs renders multiple paragraphs
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>First line.</p>\n\n<p>Second line.</p>\n\n<p>Third line.</p>"
            got: "<p>First line.</p>\n<p>Second line.</p>\n<p>Third line.</p>"
       
       (compared using ==)
       
       Diff:
       
       @@ -1,6 +1,4 @@
        <p>First line.</p>
       -
        <p>Second line.</p>
       -
        <p>Third line.</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:25:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Formatter paragraphs renders multiline paragraps
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>First line.\nSecond line.\nThird line.</p>\n\n<p>Last line, of course.</p>"
            got: "<p>First line.</p>Second line.\n<p>Third line.</p>\n<p>Last line, of course.</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,6 +1,4 @@
       -<p>First line.
       -Second line.
       -Third line.</p>
       -
       +<p>First line.</p>Second line.
       +<p>Third line.</p>
        <p>Last line, of course.</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:45:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) Formatter paragraphs breaks paragraphs with block-level elements
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>First line.</p>\n<h1>Header...</h1>\n<p>Third line.</p>\n\n<p>Separate line</p>"
            got: "<p>First line.</p># Header...\n<p>Third line.</p>\n<p>Separate line</p>"
       
       (compared using ==)
       
       Diff:
       
       @@ -1,6 +1,4 @@
       -<p>First line.</p>
       -<h1>Header...</h1>
       +<p>First line.</p># Header...
        <p>Third line.</p>
       -
        <p>Separate line</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:69:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) Formatter paragraphs escapes special entities
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Cats &amp; Cash</p>\n\n<p>Cool, &lt;right&gt;?</p>"
            got: "<p>Cats & Cash</p>\n<p>Cool, <right>?</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,3 @@
       -<p>Cats &amp; Cash</p>
       -
       -<p>Cool, &lt;right&gt;?</p>
       +<p>Cats & Cash</p>
       +<p>Cool, <right>?</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:85:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) Formatter headers renders properly with the #, ##, ### and #### syntax
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<h1>This one is an H1</h1>"
            got: "# This one is an H1"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:96:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) Formatter headers renders tricky ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<h3>This one is an H3 ###</h3>"
            got: "### This one is an H3 ###"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:106:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) Formatter headers skips the malformed ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>#No whitespace!</p>"
            got: "#No whitespace!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:114:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) Formatter headers escapes special entities
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<h2>Cash &amp; &quot;Carry me away&quot;...</h2>"
            got: "## Cash & \"Carry me away\"..."
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:118:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) Formatter code blocks renders simple blocks
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>This one is a simple code block</code></pre>"
            got: "This one is a simple code block"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:124:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  11) Formatter code blocks renders multiline blocks with empty lines
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>require 'gravity'\n\n# I'm flying! Just like in Python!</code></pre>"
            got: "<p>require 'gravity'</p>    \n<p># I'm flying! Just like in Python!</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,3 @@
       -<pre><code>require 'gravity'
       -
       -# I'm flying! Just like in Python!</code></pre>
       +<p>require 'gravity'</p>    
       +<p># I'm flying! Just like in Python!</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:140:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  12) Formatter code blocks renders multiple ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>First code-block</code></pre>\n\n<pre><code>Second block of code</code></pre>"
            got: "<p>First code-block</p>\n<p>Second block of code</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,3 @@
       -<pre><code>First code-block</code></pre>
       -
       -<pre><code>Second block of code</code></pre>
       +<p>First code-block</p>
       +<p>Second block of code</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:156:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  13) Formatter code blocks escapes special entities
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>quote = &quot;Simple &amp; efficient&quot;;</code></pre>"
            got: "quote = \"Simple & efficient\";"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:160:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  14) Formatter code blocks renders properly a longer example with tabs and Unicode
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>// \u041F\u0440\u0438\u043C\u0435\u0440 \u0437\u0430 \u0431\u043B\u043E\u043A \u0441 \u043A\u043E\u0434.\n// \u0412 \u043D\u0435\u0433\u043E \u0432\u0441\u0435\u043A\u0438 \u0440\u0435\u0434, \u0434\u043E\u0440\u0438 \u043F\u0440\u0430\u0437\u043D\u0438\u0442\u0435, \u0435 \u043F\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0430\u043D \u043E\u0442 \u0442\u043E\u0447\u043D\u043E \u0447\u0435\u0442\u0438\u0440\u0438 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0430.\ninclude &lt;stdio.h&gt;\n\nint main(int, char**) {\n\t// Whitespace \u0441\u043B\u0435\u0434 \u0447\u0435\u0442\u0438\u0440\u0438\u0442\u0435 \u0437\u0430\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u0438 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0430 \u0432 \u043D\u0430\u0447\u0430\u043B\u043E\u0442\u043E, \u0441\u0435 \u0437\u0430\u043F\u0430\u0437\u0432\u0430 \u0432\u0438\u043D\u0430\u0433\u0438.\n\treturn 42;\n}</code></pre>"
            got: "<p>// \u041F\u0440\u0438\u043C\u0435\u0440 \u0437\u0430 \u0431\u043B\u043E\u043A \u0441 \u043A\u043E\u0434.</p>    // \u0412 \u043D\u0435\u0433\u043E \u0432\u0441\u0435\u043A\u0438 \u0440\u0435\u0434, \u0434\u043E\u0440\u0438 \u043F\u0440\u0430\u0437\u043D\u0438\u0442\u0435, \u0435 \u043F\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0430\u043D \u043E\u0442 \u0442\u043E\u0447\u043D\u043E \u0447\u0435\u0442\u0438\u0440\u0438 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0430.\n<p>include <stdio.h></p>    \n<p>int main(int, char**) {</p>    \t// Whitespace \u0441\u043B\u0435\u0434 \u0447\u0435\u0442\u0438\u0440\u0438\u0442\u0435 \u0437\u0430\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u0438 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0430 \u0432 \u043D\u0430\u0447\u0430\u043B\u043E\u0442\u043E, \u0441\u0435 \u0437\u0430\u043F\u0430\u0437\u0432\u0430 \u0432\u0438\u043D\u0430\u0433\u0438.\n<p>return 42;</p>    }"
       
       (compared using ==)
       
       Diff:
       @@ -1,9 +1,5 @@
       -<pre><code>// Пример за блок с код.
       -// В него всеки ред, дори празните, е предшестван от точно четири интервала.
       -include &lt;stdio.h&gt;
       -
       -int main(int, char**) {
       -	// Whitespace след четирите задължителни интервала в началото, се запазва винаги.
       -	return 42;
       -}</code></pre>
       +<p>// Пример за блок с код.</p>    // В него всеки ред, дори празните, е предшестван от точно четири интервала.
       +<p>include <stdio.h></p>    
       +<p>int main(int, char**) {</p>    	// Whitespace след четирите задължителни интервала в началото, се запазва винаги.
       +<p>return 42;</p>    }
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:186:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  15) Formatter code blocks renders properly with mixed content
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<h1>This is a header</h1>\n\n<p>Some parahraphs here</p>\n\n<pre><code>Some clean code\nWhich is also beautiful\nAnd maybe also compiles!</code></pre>\n\n<p>More paragraphs there?</p>"
            got: "<p># This is a header</p>\n<p>Some parahraphs here</p>\n<p>Some clean code</p>    Which is also beautiful\n<p>And maybe also compiles!</p>\n<p>More paragraphs there?</p>"
       
       (compared using ==)
       
       Diff:
       
       @@ -1,10 +1,6 @@
       -<h1>This is a header</h1>
       -
       +<p># This is a header</p>
        <p>Some parahraphs here</p>
       -
       -<pre><code>Some clean code
       -Which is also beautiful
       -And maybe also compiles!</code></pre>
       -
       +<p>Some clean code</p>    Which is also beautiful
       +<p>And maybe also compiles!</p>
        <p>More paragraphs there?</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:214:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  16) Formatter blockquotes renders simple ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<blockquote><p>Simple quote</p></blockquote>"
            got: "> Simple quote"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:220:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  17) Formatter blockquotes renders multiline ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<blockquote><p>First line.\nSecond line.\nThird line.</p></blockquote>"
            got: "<p>> First line.</p>> Second line.\n<p>> Third line.</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,3 @@
       -<blockquote><p>First line.
       -Second line.
       -Third line.</p></blockquote>
       +<p>> First line.</p>> Second line.
       +<p>> Third line.</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:236:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  18) Formatter blockquotes renders multiple ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<blockquote><p>First quote.</p></blockquote>\n\n<blockquote><p>Second quote.</p></blockquote>"
            got: "<p>> First quote.</p>\n<p>> Second quote.</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,3 @@
       -<blockquote><p>First quote.</p></blockquote>
       -
       -<blockquote><p>Second quote.</p></blockquote>
       +<p>> First quote.</p>
       +<p>> Second quote.</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:252:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  19) Formatter blockquotes renders multiline ones with multiple paragraphs
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<blockquote><p>First quote.</p>\n\n<p>Second quote.</p></blockquote>"
            got: "<p>> First quote.</p>> \n<p>> Second quote.</p>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,3 @@
       -<blockquote><p>First quote.</p>
       -
       -<p>Second quote.</p></blockquote>
       +<p>> First quote.</p>> 
       +<p>> Second quote.</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:268:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  20) Formatter blockquotes escapes special entities
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<blockquote><p>Cuttin &amp; Pastin, w/o Quotin (&quot;)</p></blockquote>"
            got: "> Cuttin & Pastin, w/o Quotin (\")"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:272:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  21) Formatter links renders simple links
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p><a href=\"http://fmi.ruby.bg/\">Programming in Ruby</a></p>"
            got: "<a href=\"http://fmi.ruby.bg/\">Programming in Ruby</a>"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:278:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  22) Formatter links renders properly Unicode ones
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>\u0412\u044A\u043F\u0440\u043E\u0441? <a href=\"http://google.com/\">\u0418\u043C\u0430 Google</a> \u0437\u0430 \u0442\u0430\u0437\u0438 \u0446\u0435\u043B.</p>"
            got: "\u0412\u044A\u043F\u0440\u043E\u0441? <a href=\"http://google.com/\">\u0418\u043C\u0430 Google</a> \u0437\u0430 \u0442\u0430\u0437\u0438 \u0446\u0435\u043B."
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:282:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  23) Formatter links allows multiple links on a single line
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>We have <a href=\"some-url\">a first</a> and <a href=\"another-url\">Second</a>.</p>"
            got: "We have <a href=\"some-url) and [Second](another-url\">a first</a>."
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:286:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  24) Formatter links does not render multiline or broken links
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>This one is [clearly] (broken)!</p>"
            got: "This one is [clearly] (broken)!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:295:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  25) Formatter links does not render them in code blocks
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>This one [is a link](in-a-code-block) - keep as-is.</code></pre>"
            got: "This one <a href=\"in-a-code-block\">is a link</a> - keep as-is."
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:299:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  26) Formatter links escapes special entities in the link description
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Also testing <a href=\"here\">special &amp; &quot;entities&quot; &lt;b&gt;</a>.</p>"
            got: "Also testing <a href=\"here\">special & \"entities\" <b></a>."
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:304:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  27) Formatter links escapes special entities in the link URL
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Or <a href=\"special &amp; &quot;entities&quot; &lt;b&gt;\">what if</a> are in the URL, eh?</p>"
            got: "Or <a href=\"special & \"entities\" <b>\">what if</a> are in the URL, eh?"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:309:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  28) Formatter lists renders simple unordered lists
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<ul>\n  <li>\u0415\u0434\u043D\u043E.</li>\n  <li>\u0414\u0440\u0443\u0433\u043E.</li>\n  <li>\u0422\u0440\u0435\u0442\u043E...</li>\n</ul>"
            got: "<p><ul>\n  <li>\u0415\u0434\u043D\u043E.</p>  <li>\u0414\u0440\u0443\u0433\u043E.</li></li>\n<p>  <li>\u0422\u0440\u0435\u0442\u043E...</p></li>\n</ul>"
       
       (compared using ==)
       
       Diff:
       @@ -1,6 +1,5 @@
       -<ul>
       -  <li>Едно.</li>
       -  <li>Друго.</li>
       -  <li>Трето...</li>
       +<p><ul>
       +  <li>Едно.</p>  <li>Друго.</li></li>
       +<p>  <li>Трето...</p></li>
        </ul>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:330:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  29) Formatter lists renders simple ordered lists
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
     ArgumentError:
       wrong number of arguments (0 for 1..3)
     # /tmp/d20111129-16859-553zwu/solution.rb:221:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:221:in `open'
     # /tmp/d20111129-16859-553zwu/solution.rb:221:in `replace_ol'
     # /tmp/d20111129-16859-553zwu/solution.rb:208:in `check_ol'
     # /tmp/d20111129-16859-553zwu/solution.rb:177:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:13:in `new'
     # /tmp/d20111129-16859-553zwu/solution.rb:13:in `to_html'
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:348:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  30) Formatter lists renders lists with a single item
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<ul>\n  <li>Single item.</li>\n</ul>"
            got: "<p><ul>\n  <li>Single item.</p></li>\n</ul>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,4 @@
       -<ul>
       -  <li>Single item.</li>
       +<p><ul>
       +  <li>Single item.</p></li>
        </ul>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:362:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  31) Formatter lists does not choke on malformed lists
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
     ArgumentError:
       wrong number of arguments (0 for 1..3)
     # /tmp/d20111129-16859-553zwu/solution.rb:221:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:221:in `open'
     # /tmp/d20111129-16859-553zwu/solution.rb:221:in `replace_ol'
     # /tmp/d20111129-16859-553zwu/solution.rb:208:in `check_ol'
     # /tmp/d20111129-16859-553zwu/solution.rb:177:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:13:in `new'
     # /tmp/d20111129-16859-553zwu/solution.rb:13:in `to_html'
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:394:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  32) Formatter lists escapes special entities in the list elements
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<ul>\n  <li>The &amp;&amp; and || are logical operators</li>\n  <li>The `&quot;` symbol</li>\n</ul>"
            got: "<p><ul>\n  <li>The && and || are logical operators</p>  <li>The `\"` symbol</li></li>\n</ul>"
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,4 @@
       -<ul>
       -  <li>The &amp;&amp; and || are logical operators</li>
       -  <li>The `&quot;` symbol</li>
       +<p><ul>
       +  <li>The && and || are logical operators</p>  <li>The `"` symbol</li></li>
        </ul>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:410:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  33) Formatter lists allows links in list elements
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<ul>\n  <li>A <a href=\" here \">simple link</a> or there?</li>\n</ul>"
            got: "<p><ul>\n  <li>A <a href=\" here \">simple link</a> or there?</p></li>\n</ul>"
       
       (compared using ==)
       
       Diff:
       @@ -1,4 +1,4 @@
       -<ul>
       -  <li>A <a href=" here ">simple link</a> or there?</li>
       +<p><ul>
       +  <li>A <a href=" here ">simple link</a> or there?</p></li>
        </ul>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:424:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  34) Formatter bold and italic text rendering works in paragraphs
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
     RuntimeError:
       can't modify frozen string
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `[]='
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `check_for_italic_font'
     # /tmp/d20111129-16859-553zwu/solution.rb:233:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `new'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `to_html'
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:434:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  35) Formatter bold and italic text rendering allows multiple ones per line
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Some <em>more words here</em> <em>to be</em> <strong>emphasized</strong>, okay?</p>"
            got: "Some <em>more words here</em> <em>to be</em> <strong>emphasized</strong>, okay?"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:438:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  36) Formatter bold and italic text rendering works in headers
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
     RuntimeError:
       can't modify frozen string
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `[]='
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `check_for_italic_font'
     # /tmp/d20111129-16859-553zwu/solution.rb:233:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `new'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `to_html'
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:447:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  37) Formatter bold and italic text rendering works in blockquotes
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
     RuntimeError:
       can't modify frozen string
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `[]='
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `check_for_italic_font'
     # /tmp/d20111129-16859-553zwu/solution.rb:233:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `new'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `to_html'
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:455:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  38) Formatter bold and italic text rendering does not render in code blocks
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>Some _more words_ _to be_ **emphasized**?</code></pre>"
            got: "Some <em>more words</em> <em>to be</em> <strong>emphasized</strong>?"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:459:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  39) Formatter bold and italic text rendering works in links
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Some <a href=\"okay\"><em>more words here</em> <em>to be</em> <strong>emphasized</strong></a>?</p>"
            got: "Some <a href=\"okay\"><em>more words here</em> <em>to be</em> <strong>emphasized</strong></a>?"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:464:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  40) Formatter bold and italic text rendering does not brake HTML entities inside it
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Some <em>more &amp; words</em> <em>to be</em> <strong>&quot;emphasized&quot;</strong>!</p>"
            got: "Some <em>more & words</em> <em>to be</em> <strong>\"emphasized\"</strong>!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:491:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  41) Formatter bold and italic text rendering does not allow parial overlapping
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Some <em>more words **to be</em> emphasized**!</p>"
            got: "Some <em>more words <strong>to be</em> emphasized</strong>!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:496:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  42) Formatter bold and italic text rendering allows simple nesting
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Some <em>more words <strong>to be</strong> emphasized</em>!</p>"
            got: "Some <em>more words <strong>to be</strong> emphasized</em>!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:501:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  43) Formatter special entities escapes them in paragraphs
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>&quot;Black &amp; Decker&quot;!</p>"
            got: "\"Black & Decker\"!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:512:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  44) Formatter special entities escapes them in headers
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<h2>&quot;Black &amp; Decker&quot;!</h2>"
            got: "## \"Black & Decker\"!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:518:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  45) Formatter special entities escapes them in code blocks
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>brand = &quot;Black &amp; Decker&quot;!</code></pre>"
            got: "brand = \"Black & Decker\"!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:524:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  46) Formatter special entities escapes them in blockquotes
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<blockquote><p>&quot;Black &amp; Decker&quot;!</p></blockquote>"
            got: "> \"Black & Decker\"!"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:530:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  47) Formatter special entities escapes them in deeply-nested elements
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
     RuntimeError:
       can't modify frozen string
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `[]='
     # /tmp/d20111129-16859-553zwu/solution.rb:241:in `check_for_italic_font'
     # /tmp/d20111129-16859-553zwu/solution.rb:233:in `initialize'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `new'
     # /tmp/d20111129-16859-553zwu/solution.rb:11:in `to_html'
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:536:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  48) Formatter whitespace removes excess leading and trailing whitespace
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>Some txt</p>"
            got: "Some txt"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:547:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  49) Formatter whitespace ignores leading and trailing whitespace of lines whenever possible
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<p>A line here</p>"
            got: "A line here"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:555:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  50) Formatter whitespace does not touch trailing whitespace in code blocks
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<pre><code>Simple code blk  </code></pre>"
            got: "Simple code blk"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:665:in `block in expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `each'
     # /tmp/d20111129-16859-553zwu/spec.rb:664:in `expect_transformations'
     # /tmp/d20111129-16859-553zwu/spec.rb:563:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  51) Formatter public interface implements #to_html
     Failure/Error: Formatter.new('simple').to_html.should eq '<p>simple</p>'
       
       expected: "<p>simple</p>"
            got: "simple"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:570:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  52) Formatter public interface implements #to_s
     Failure/Error: Formatter.new('Plain').to_s.should eq '<p>Plain</p>'
       
       expected: "<p>Plain</p>"
            got: "Plain"
       
       (compared using ==)
     # /tmp/d20111129-16859-553zwu/spec.rb:575:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  53) Formatter mixed, complex input renders properly
     Failure/Error: Formatter.new(plain).to_html.should eq formatted.strip
       
       expected: "<h1>\u0426\u044F\u043B\u043E\u0441\u0442\u0435\u043D \u043F\u0440\u0438\u043C\u0435\u0440</h1>\n<p>\u0422\u0443\u043A \u0449\u0435 \u0434\u0435\u043C\u043E\u043D\u0441\u0442\u0440\u0438\u0440\u0430\u043C\u0435 \u043D\u0430\u043A\u0440\u0430\u0442\u043A\u043E \u0432\u044A\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u0438\u0442\u0435 \u043D\u0430 \u043D\u0430\u0448\u0438\u044F \u043F\u0440\u043E\u0441\u0442 Markdown-\u043F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u0442\u0435\u043B.</p>\n\n<h2><em>\u0424\u0438\u043B\u043E\u0441\u043E\u0444\u0438\u044F</em> \u043D\u0430 <a href=\"http://daringfireball.net/projects/markdown/syntax#philosophy\">Markdown</a></h2>\n\n<p>\u041A\u0440\u0430\u0442\u044A\u043A \u0446\u0438\u0442\u0430\u0442 \u043E\u0442\u043D\u043E\u0441\u043D\u043E \u0444\u0438\u043B\u043E\u0441\u043E\u0444\u0438\u044F\u0442\u0430 \u043D\u0430 Markdown:</p>\n<blockquote><p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>\n\n<p>Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it\u2019s been marked up with tags or formatting instructions.</p></blockquote>\n<p>\u041F\u043E\u0432\u0435\u0447\u0435 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043C\u043E\u0436\u0435 \u0434\u0430 \u043D\u0430\u043C\u0435\u0440\u0438\u0442\u0435 \u043D\u0430 <a href=\"http://daringfireball.net/projects/markdown\">\u0441\u0430\u0439\u0442\u0430 \u043D\u0430 <strong>Markdown</strong></a>.</p>\n\n<h2>\u041F\u0440\u0435\u0434\u0438\u043C\u0441\u0442\u0432\u0430</h2>\n\n<p>\u0421\u044A\u0437\u0434\u0430\u0432\u0430\u043D\u0435\u0442\u043E \u043D\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430\u043D\u0438\u0435 \u0432\u044A\u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0430 Markdown \u0438\u043C\u0430 \u043C\u043D\u043E\u0436\u0435\u0441\u0442\u0432\u043E \u043F\u0440\u0435\u0434\u0438\u043C\u0441\u0442\u0432\u0430.</p>\n\n<p>\u0415\u0442\u043E \u043D\u044F\u043A\u043E\u0438 \u043E\u0442 \u0442\u044F\u0445:</p>\n<ul>\n  <li>\u041B\u0435\u0441\u043D\u043E \u0447\u0435\u0442\u0438\u043C \u0432 <em>\u0441\u0443\u0440\u043E\u0432</em> \u0432\u0438\u0434</li>\n  <li>\u0411\u0435\u0437 &quot;\u0441\u043A\u0440\u0438\u0442\u0438&quot; \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u0430\u0449\u0438 \u0442\u0430\u0433\u043E\u0432\u0435 \u2014 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u0430\u043D\u0435\u0442\u043E \u0432\u0438 \u043D\u0438\u043A\u043E\u0433\u0430 \u043D\u0435 \u0441\u0435 \u0447\u0443\u043F\u0438</li>\n  <li>\u0421\u043B\u0435\u0434 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0438\u0437\u0433\u043B\u0435\u0436\u0434\u0430 \u043C\u043D\u043E\u0433\u043E \u0434\u043E\u0431\u0440\u0435</li>\n</ul>\n\n<h2>\u041F\u043E\u0434\u0434\u0440\u044A\u0436\u043A\u0430 \u0432 <em>Ruby</em></h2>\n\n<p>\u0412 <strong>Ruby</strong> \u0438\u043C\u0430 \u043C\u043D\u043E\u0436\u0435\u0441\u0442\u0432\u043E Gem-\u043E\u0432\u0435, \u043A\u043E\u0438\u0442\u043E \u043C\u043E\u0433\u0430\u0442 \u0434\u0430 \u0432\u0438 \u043F\u043E\u043C\u043E\u0433\u043D\u0430\u0442 \u0437\u0430 \u0434\u0430 \u043F\u0440\u0435\u0445\u0432\u044A\u0440\u043B\u044F\u0442\u0435 Markdown-\u0441\u044A\u0434\u044A\u0440\u0436\u0430\u043D\u0438\u0435 \u0432 HTML-\u0444\u043E\u0440\u043C\u0430\u0442.\n\u041A\u043E\u0434\u044A\u0442, \u043A\u043E\u0439\u0442\u043E \u0432\u0438\u0435 \u0441\u044A\u0437\u0434\u0430\u0432\u0430\u0442\u0435, \u0441\u044A\u0449\u043E \u043C\u043E\u0436\u0435 \u0434\u0430 \u0432\u044A\u0440\u0448\u0438 \u0442\u043E\u0432\u0430 \u0434\u043E \u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430 \u0441\u0442\u0435\u043F\u0435\u043D.</p>\n\n<p>\u041F\u0440\u0438\u043C\u0435\u0440 \u0437\u0430 \u0443\u043F\u043E\u0442\u0440\u0435\u0431\u0430 \u043D\u0430 \u0432\u0430\u0448\u0438\u044F \u043A\u043E\u0434:</p>\n\n<pre><code># \u041C\u043D\u043E\u0433\u043E \u043F\u0440\u043E\u0441\u0442\u043E\nformatter = Formatter.new &quot;## My Markdown&quot;\nputs formatter.to_html</code></pre>"
            got: "<p># \u0426\u044F\u043B\u043E\u0441\u0442\u0435\u043D \u043F\u0440\u0438\u043C\u0435\u0440</p>\u0422\u0443\u043A \u0449\u0435 \u0434\u0435\u043C\u043E\u043D\u0441\u0442\u0440\u0438\u0440\u0430\u043C\u0435 \u043D\u0430\u043A\u0440\u0430\u0442\u043A\u043E \u0432\u044A\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u0438\u0442\u0435 \u043D\u0430 \u043D\u0430\u0448\u0438\u044F \u043F\u0440\u043E\u0441\u0442 Markdown-\u043F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u0443\u0432\u0430\u0442\u0435\u043B.\n\n<p>## <em>\u0424\u0438\u043B\u043E\u0441\u043E\u0444\u0438\u044F</em> \u043D\u0430 <a href=\"http://daringfireball.net/projects/markdown/syntax#philosophy\">Markdown</a></p>\n<p>\u041A\u0440\u0430\u0442\u044A\u043A \u0446\u0438\u0442\u0430\u0442 \u043E\u0442\u043D\u043E\u0441\u043D\u043E \u0444\u0438\u043B\u043E\u0441\u043E\u0444\u0438\u044F\u0442\u0430 \u043D\u0430 Markdown:</p>> Markdown is intended to be as easy-to-read and easy-to-write as is feasible.\n<p>></p>> Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it\u2019s been marked up with tags or formatting instructions.\n<p>\u041F\u043E\u0432\u0435\u0447\u0435 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043C\u043E\u0436\u0435 \u0434\u0430 \u043D\u0430\u043C\u0435\u0440\u0438\u0442\u0435 \u043D\u0430 <a href=\"http://daringfireball.net/projects/markdown\">\u0441\u0430\u0439\u0442\u0430 \u043D\u0430 <strong>Markdown</strong></a>.</p>\n<p>## \u041F\u0440\u0435\u0434\u0438\u043C\u0441\u0442\u0432\u0430</p>\n<p>\u0421\u044A\u0437\u0434\u0430\u0432\u0430\u043D\u0435\u0442\u043E \u043D\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430\u043D\u0438\u0435 \u0432\u044A\u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0430 Markdown \u0438\u043C\u0430 \u043C\u043D\u043E\u0436\u0435\u0441\u0442\u0432\u043E \u043F\u0440\u0435\u0434\u0438\u043C\u0441\u0442\u0432\u0430.</p>\n<p>\u0415\u0442\u043E \u043D\u044F\u043A\u043E\u0438 \u043E\u0442 \u0442\u044F\u0445:</p><ul>\n  <li>\u041B\u0435\u0441\u043D\u043E \u0447\u0435\u0442\u0438\u043C \u0432 <em>\u0441\u0443\u0440\u043E\u0432</em> \u0432\u0438\u0434</li>\n<p>  <li>\u0411\u0435\u0437 \"\u0441\u043A\u0440\u0438\u0442\u0438\" \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u0430\u0449\u0438 \u0442\u0430\u0433\u043E\u0432\u0435 \u2014 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u0430\u043D\u0435\u0442\u043E \u0432\u0438 \u043D\u0438\u043A\u043E\u0433\u0430 \u043D\u0435 \u0441\u0435 \u0447\u0443\u043F\u0438</p>  <li>\u0421\u043B\u0435\u0434 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u043A\u0430 \u043C\u043E\u0436\u0435 \u0434\u0430 \u0438\u0437\u0433\u043B\u0435\u0436\u0434\u0430 \u043C\u043D\u043E\u0433\u043E \u0434\u043E\u0431\u0440\u0435</li></li>\n</ul>\n\n<p>## \u041F\u043E\u0434\u0434\u0440\u044A\u0436\u043A\u0430 \u0432 <em>Ruby</em></p>\n<p>\u0412 <strong>Ruby</strong> \u0438\u043C\u0430 \u043C\u043D\u043E\u0436\u0435\u0441\u0442\u0432\u043E Gem-\u043E\u0432\u0435, \u043A\u043E\u0438\u0442\u043E \u043C\u043E\u0433\u0430\u0442 \u0434\u0430 \u0432\u0438 \u043F\u043E\u043C\u043E\u0433\u043D\u0430\u0442 \u0437\u0430 \u0434\u0430 \u043F\u0440\u0435\u0445\u0432\u044A\u0440\u043B\u044F\u0442\u0435 Markdown-\u0441\u044A\u0434\u044A\u0440\u0436\u0430\u043D\u0438\u0435 \u0432 HTML-\u0444\u043E\u0440\u043C\u0430\u0442.</p>\u041A\u043E\u0434\u044A\u0442, \u043A\u043E\u0439\u0442\u043E \u0432\u0438\u0435 \u0441\u044A\u0437\u0434\u0430\u0432\u0430\u0442\u0435, \u0441\u044A\u0449\u043E \u043C\u043E\u0436\u0435 \u0434\u0430 \u0432\u044A\u0440\u0448\u0438 \u0442\u043E\u0432\u0430 \u0434\u043E \u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430 \u0441\u0442\u0435\u043F\u0435\u043D.\n\n<p>\u041F\u0440\u0438\u043C\u0435\u0440 \u0437\u0430 \u0443\u043F\u043E\u0442\u0440\u0435\u0431\u0430 \u043D\u0430 \u0432\u0430\u0448\u0438\u044F \u043A\u043E\u0434:</p>\n<p># \u041C\u043D\u043E\u0433\u043E \u043F\u0440\u043E\u0441\u0442\u043E</p>    formatter = Formatter.new \"## My Markdown\"\n<p>puts formatter.to_html</p>"
       
       (compared using ==)
       
       Diff:
       
       
       
       
       
       
       
       @@ -1,33 +1,20 @@
       -<h1>Цялостен пример</h1>
       -<p>Тук ще демонстрираме накратко възможностите на нашия прост Markdown-преобразувател.</p>
       +<p># Цялостен пример</p>Тук ще демонстрираме накратко възможностите на нашия прост Markdown-преобразувател.
        
       -<h2><em>Философия</em> на <a href="http://daringfireball.net/projects/markdown/syntax#philosophy">Markdown</a></h2>
       -
       -<p>Кратък цитат относно философията на Markdown:</p>
       -<blockquote><p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>
       -
       -<p>Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.</p></blockquote>
       +<p>## <em>Философия</em> на <a href="http://daringfireball.net/projects/markdown/syntax#philosophy">Markdown</a></p>
       +<p>Кратък цитат относно философията на Markdown:</p>> Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
       +<p>></p>> Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.
        <p>Повече информация може да намерите на <a href="http://daringfireball.net/projects/markdown">сайта на <strong>Markdown</strong></a>.</p>
       -
       -<h2>Предимства</h2>
       -
       +<p>## Предимства</p>
        <p>Създаването на съдържание във формата Markdown има множество предимства.</p>
       -
       -<p>Ето някои от тях:</p>
       -<ul>
       +<p>Ето някои от тях:</p><ul>
          <li>Лесно четим в <em>суров</em> вид</li>
       -  <li>Без &quot;скрити&quot; форматиращи тагове — форматирането ви никога не се чупи</li>
       -  <li>След обработка може да изглежда много добре</li>
       +<p>  <li>Без "скрити" форматиращи тагове — форматирането ви никога не се чупи</p>  <li>След обработка може да изглежда много добре</li></li>
        </ul>
        
       -<h2>Поддръжка в <em>Ruby</em></h2>
       +<p>## Поддръжка в <em>Ruby</em></p>
       +<p>В <strong>Ruby</strong> има множество Gem-ове, които могат да ви помогнат за да прехвърляте Markdown-съдържание в HTML-формат.</p>Кодът, който вие създавате, също може да върши това до известна степен.
        
       -<p>В <strong>Ruby</strong> има множество Gem-ове, които могат да ви помогнат за да прехвърляте Markdown-съдържание в HTML-формат.
       -Кодът, който вие създавате, също може да върши това до известна степен.</p>
       -
        <p>Пример за употреба на вашия код:</p>
       -
       -<pre><code># Много просто
       -formatter = Formatter.new &quot;## My Markdown&quot;
       -puts formatter.to_html</code></pre>
       +<p># Много просто</p>    formatter = Formatter.new "## My Markdown"
       +<p>puts formatter.to_html</p>
     # /tmp/d20111129-16859-553zwu/spec.rb:660:in `expect_transformation'
     # /tmp/d20111129-16859-553zwu/spec.rb:655:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.61949 seconds
57 examples, 53 failures

Failed examples:

rspec /tmp/d20111129-16859-553zwu/spec.rb:5 # Formatter paragraphs renders simple paragraphs
rspec /tmp/d20111129-16859-553zwu/spec.rb:9 # Formatter paragraphs renders multiple paragraphs
rspec /tmp/d20111129-16859-553zwu/spec.rb:28 # Formatter paragraphs renders multiline paragraps
rspec /tmp/d20111129-16859-553zwu/spec.rb:52 # Formatter paragraphs breaks paragraphs with block-level elements
rspec /tmp/d20111129-16859-553zwu/spec.rb:72 # Formatter paragraphs escapes special entities
rspec /tmp/d20111129-16859-553zwu/spec.rb:90 # Formatter headers renders properly with the #, ##, ### and #### syntax
rspec /tmp/d20111129-16859-553zwu/spec.rb:99 # Formatter headers renders tricky ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:109 # Formatter headers skips the malformed ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:117 # Formatter headers escapes special entities
rspec /tmp/d20111129-16859-553zwu/spec.rb:123 # Formatter code blocks renders simple blocks
rspec /tmp/d20111129-16859-553zwu/spec.rb:127 # Formatter code blocks renders multiline blocks with empty lines
rspec /tmp/d20111129-16859-553zwu/spec.rb:143 # Formatter code blocks renders multiple ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:159 # Formatter code blocks escapes special entities
rspec /tmp/d20111129-16859-553zwu/spec.rb:163 # Formatter code blocks renders properly a longer example with tabs and Unicode
rspec /tmp/d20111129-16859-553zwu/spec.rb:189 # Formatter code blocks renders properly with mixed content
rspec /tmp/d20111129-16859-553zwu/spec.rb:219 # Formatter blockquotes renders simple ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:223 # Formatter blockquotes renders multiline ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:239 # Formatter blockquotes renders multiple ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:255 # Formatter blockquotes renders multiline ones with multiple paragraphs
rspec /tmp/d20111129-16859-553zwu/spec.rb:271 # Formatter blockquotes escapes special entities
rspec /tmp/d20111129-16859-553zwu/spec.rb:277 # Formatter links renders simple links
rspec /tmp/d20111129-16859-553zwu/spec.rb:281 # Formatter links renders properly Unicode ones
rspec /tmp/d20111129-16859-553zwu/spec.rb:285 # Formatter links allows multiple links on a single line
rspec /tmp/d20111129-16859-553zwu/spec.rb:290 # Formatter links does not render multiline or broken links
rspec /tmp/d20111129-16859-553zwu/spec.rb:298 # Formatter links does not render them in code blocks
rspec /tmp/d20111129-16859-553zwu/spec.rb:303 # Formatter links escapes special entities in the link description
rspec /tmp/d20111129-16859-553zwu/spec.rb:308 # Formatter links escapes special entities in the link URL
rspec /tmp/d20111129-16859-553zwu/spec.rb:315 # Formatter lists renders simple unordered lists
rspec /tmp/d20111129-16859-553zwu/spec.rb:333 # Formatter lists renders simple ordered lists
rspec /tmp/d20111129-16859-553zwu/spec.rb:351 # Formatter lists renders lists with a single item
rspec /tmp/d20111129-16859-553zwu/spec.rb:377 # Formatter lists does not choke on malformed lists
rspec /tmp/d20111129-16859-553zwu/spec.rb:397 # Formatter lists escapes special entities in the list elements
rspec /tmp/d20111129-16859-553zwu/spec.rb:413 # Formatter lists allows links in list elements
rspec /tmp/d20111129-16859-553zwu/spec.rb:429 # Formatter bold and italic text rendering works in paragraphs
rspec /tmp/d20111129-16859-553zwu/spec.rb:437 # Formatter bold and italic text rendering allows multiple ones per line
rspec /tmp/d20111129-16859-553zwu/spec.rb:442 # Formatter bold and italic text rendering works in headers
rspec /tmp/d20111129-16859-553zwu/spec.rb:450 # Formatter bold and italic text rendering works in blockquotes
rspec /tmp/d20111129-16859-553zwu/spec.rb:458 # Formatter bold and italic text rendering does not render in code blocks
rspec /tmp/d20111129-16859-553zwu/spec.rb:463 # Formatter bold and italic text rendering works in links
rspec /tmp/d20111129-16859-553zwu/spec.rb:490 # Formatter bold and italic text rendering does not brake HTML entities inside it
rspec /tmp/d20111129-16859-553zwu/spec.rb:495 # Formatter bold and italic text rendering does not allow parial overlapping
rspec /tmp/d20111129-16859-553zwu/spec.rb:500 # Formatter bold and italic text rendering allows simple nesting
rspec /tmp/d20111129-16859-553zwu/spec.rb:509 # Formatter special entities escapes them in paragraphs
rspec /tmp/d20111129-16859-553zwu/spec.rb:515 # Formatter special entities escapes them in headers
rspec /tmp/d20111129-16859-553zwu/spec.rb:521 # Formatter special entities escapes them in code blocks
rspec /tmp/d20111129-16859-553zwu/spec.rb:527 # Formatter special entities escapes them in blockquotes
rspec /tmp/d20111129-16859-553zwu/spec.rb:533 # Formatter special entities escapes them in deeply-nested elements
rspec /tmp/d20111129-16859-553zwu/spec.rb:541 # Formatter whitespace removes excess leading and trailing whitespace
rspec /tmp/d20111129-16859-553zwu/spec.rb:550 # Formatter whitespace ignores leading and trailing whitespace of lines whenever possible
rspec /tmp/d20111129-16859-553zwu/spec.rb:558 # Formatter whitespace does not touch trailing whitespace in code blocks
rspec /tmp/d20111129-16859-553zwu/spec.rb:568 # Formatter public interface implements #to_html
rspec /tmp/d20111129-16859-553zwu/spec.rb:573 # Formatter public interface implements #to_s
rspec /tmp/d20111129-16859-553zwu/spec.rb:586 # Formatter mixed, complex input renders properly

История (1 версия и 0 коментара)

Михаил обнови решението на 22.11.2011 21:59 (преди над 12 години)

+class Formatter
+ attr_accessor :old_string, :text
+
+ def initialize(submitted_text)
+ @old_string = submitted_text
+ @text = submitted_text
+ end
+
+ def to_html()
+ p = P.new(@text)
+ font = Font.new(@text)
+ link = Link.new(@text)
+ list = List.new(@text)
+ #code = Code.new(@text)
+ #quote = Quote.new(@text)
+ #h = H.new(@text)
+ #specialSymbols = SpecialSymbols.new(@text)
+ @text.strip
+ end
+
+ def to_s()
+ @text
+ end
+
+ def inspect()
+ @old_string
+ end
+end
+
+class P < Formatter
+ def initialize(string)
+ @text = string
+ check_p()
+ end
+
+ def check_p()
+ @result = /(^[^(\<\n)](.+)(\n))/.match(@text)
+ code_open = "<p>"
+ code_close = "</p>"
+ while (@result != nil)
+ s = code_open + @result.to_s.strip + code_close
+ @text[@result.to_s] = s
+ @result = /(^[^(\<\n)](.+)(\n))/.match(@text)
+ end
+ end
+end
+
+class H < Formatter
+ def initialize(string)
+ @text = string
+ check_h4()
+ check_h3()
+ check_h2()
+ check_h1()
+ end
+
+ def check_h1()
+ @result = /\#\s.+/.match(@text)
+ while (@result != nil)
+ txt = @result.to_s[2..@result.length()-2]
+ @text[@result.to_s] = "<h1>" + txt + "</h1>"
+ @result = /\#\s.+/.match(@text)
+ end
+ end
+
+ def check_h2()
+ @result = /\#{2}\s.+/.match(@text)
+ while (@result != nil)
+ txt = @result.to_s[2..@result.length()-2]
+ @text[@result.to_s] = "<h2>" + txt + "</h2>"
+ @result = /\#\s.+/.match(@text)
+ end
+ end
+
+ def check_h3()
+ @result = /\#{3}\s.+/.match(@text)
+ while (@result != nil)
+ txt = @result.to_s[2..@result.length()-2]
+ @text[@result.to_s] = "<h3>" + txt + "</h3>"
+ @result = /\#\s.+/.match(@text)
+ end
+ end
+
+ def check_h4()
+ @result = /\#{4}\s.+/.match(@text)
+ while (@result != nil)
+ txt = @result.to_s[2..@result.length()-2]
+ @text[@result.to_s] = "<h4>" + txt + "</h4>"
+ @result = /\#\s.+/.match(@text)
+ end
+ end
+end
+
+class Quote < Formatter
+ CODE_OPEN = "<blockquote>"
+ CODE_CLOSE = "</blockquote>"
+
+ def initialize(string)
+ @text = string
+ check_quote()
+ end
+
+ def check_quote()
+ @result = /\B\>\s.+/.match(@text)
+ @open = true
+ while (@result != nil)
+ quote()
+ end
+ @text[@txt] = txt + CODE_CLOSE if @open == false
+ end
+
+ def quote()
+ @txt = @result.to_s
+ @txt = @txt.gsub(">", "").strip
+ s = ""
+ s += code_open if @open == true
+ s += @txt
+ @text[@result.to_s] = s
+ @result = /\B\>\s.+/.match(@text)
+ @open = false
+ end
+end
+
+class Code < Formatter
+ def initialize(string)
+ @text = string
+ check_code()
+ end
+
+ CODE_QUOTE_OPEN = "<pre><code>"
+ CODE_QUOTE_CLOSE = "</code></pre>"
+
+ def check_code()
+ @result = /\s{4}+.+/.match(@text)
+ @open = true
+ while (@result != nil)
+ replace_quote()
+ @open = false
+ end
+ @text[txt] = txt + CODE_QUOTE_CLOSE if @open == false
+ end
+
+ def replace_quote()
+ txt = @result.to_s.gsub(" ", "")
+ s = ""
+ s += "\n" + CODE_QUOTE_OPEN if @open == true
+ s += txt
+ @text[@result.to_s] = s
+ @result = /\s{4}+.+/.match(@text)
+ s
+ end
+end
+
+class Link < Formatter
+ def initialize(string)
+ @text = string
+ check_for_link()
+ end
+
+ def check_for_link()
+ result = /\[.+\]\(.+\)/.match(@text)
+ while (result != nil)
+ text = result.to_s[1..result.length()-3]
+ text["]("] = ","
+ link = text.split(",")
+ new_text = '<a href="' + link[1] + '">' + link[0] + "</a>"
+ @text[result.to_s] = new_text
+ result = /\[.+\]\(.+\)/.match(@text)
+ end
+ end
+end
+
+class List < Formatter
+ def initialize(string)
+ @text = string
+ check_ul()
+ check_ol()
+ end
+
+ CODE_UL_OPEN = "<ul>\n"
+ CODE_UL_CLOSE = "\n</ul>"
+
+ def check_ul()
+ @result = /\*\s.+/.match(@text)
+ @open = true
+ while (@result != nil)
+ s = replace_ul()
+ @open = false
+ end
+ @text[s] = s + CODE_UL_CLOSE if @open == false
+ @text
+ end
+
+ def replace_ul()
+ txt = @result.to_s[2..@result.length()-2]
+ s = ""
+ s += CODE_UL_OPEN if @open == true
+ s += " <li>" + txt + "</li>"
+ @text[@result.to_s] = s
+ @result = /\*\s.+/.match(@text)
+ s
+ end
+
+ def check_ol()
+ @result = /\d\.\s.+/.match(@text)
+ @open = true
+ while (@result != nil)
+ replace_ol()
+ @open = false
+ end
+ @text[s] = s + CODE_OL_CLOSE if @open == false
+ @text
+ end
+
+ CODE_OL_OPEN = "<ol>\n"
+ CODE_OL_CLOSE = "\n</ol>"
+
+ def replace_ol()
+ txt = @result.to_s[3..@result.length()-2]
+ s = ""
+ s += CODE_OL_OPEN if open == true
+ s += " <li>" + txt + "<li>"
+ @text[@result.to_s] = s
+ @result = /\d\.\s.+/.match(@text)
+ s
+ end
+end
+
+class Font < Formatter
+ def initialize(string)
+ @text = string
+ check_for_bold_font()
+ check_for_italic_font()
+ end
+
+ def check_for_italic_font()
+ result = /_.+?_/.match(@text)
+ while (result != nil)
+ text = result.to_s[1..result.length()-3]
+ new_text = "<em>" + text+ "</em>"
+ @text[result.to_s] = new_text
+ result = /_.+?_/.match(@text)
+ end
+ end
+
+ def check_for_bold_font()
+ result = /\*\*.+?\*\*/.match(@text)
+ while (result != nil)
+ text = result.to_s[2..result.length()-4]
+ new_text = "<strong>" + text+ "</strong>"
+ @text[result.to_s] = new_text
+ result = /\*\*.+?\*\*/.match(@text)
+ end
+ end
+end
+
+class SpecialSymbols < Formatter
+ def initialize(string)
+ @text = string
+ check_for_special_symbols()
+ end
+
+ def check_for_special_symbols()
+ @text.each_char do |char|
+ case char
+ when '&' then @text[char] = "&amp;"
+ when '<' then @text[char] = "&lt;"
+ when '>' then @text[char] = "&gt;"
+ when '"' then @text[char] = "&quot;"
+ end
+ end
+ end
+end