From 2d303d54a051f190f3dd1746e822e5e70d65875e Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Sat, 27 Aug 2011 02:40:40 -0500 Subject: [PATCH] Better text/html serialization For the Andrew Staceys of this world: deal with empty element in a more text/html-friendly fashion. --- test/unit/page_renderer_test.rb | 10 +++++----- vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb | 4 ++-- vendor/plugins/maruku/lib/maruku/output/to_html.rb | 4 ++-- vendor/plugins/maruku/spec/block_docs/alt.md | 2 +- vendor/plugins/maruku/spec/block_docs/footnotes.md | 2 +- vendor/plugins/maruku/spec/block_docs/hrule.md | 2 +- vendor/plugins/maruku/spec/block_docs/html2.md | 4 ++-- vendor/plugins/maruku/spec/block_docs/html4.md | 2 +- vendor/plugins/maruku/spec/block_docs/html5.md | 2 +- vendor/plugins/maruku/spec/block_docs/ie.md | 6 +++--- vendor/plugins/maruku/spec/block_docs/images.md | 10 +++++----- vendor/plugins/maruku/spec/block_docs/images2.md | 4 ++-- vendor/plugins/maruku/spec/block_docs/inline_html.md | 6 +++--- .../maruku/spec/block_docs/lists_after_paragraph.md | 6 +++--- vendor/plugins/maruku/spec/block_docs/loss.md | 2 +- .../maruku/spec/block_docs/notyet/triggering.md | 4 ++-- vendor/plugins/maruku/spec/block_docs/paragraphs.md | 2 +- .../maruku/spec/block_docs/pending/empty_cells.md | 4 ++-- vendor/plugins/maruku/spec/block_docs/syntax_hl.md | 2 +- vendor/plugins/maruku/spec/block_docs/wrapping.md | 4 ++-- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb index cbea5c43..c690087c 100644 --- a/test/unit/page_renderer_test.rb +++ b/test/unit/page_renderer_test.rb @@ -45,7 +45,7 @@ class PageRendererTest < ActiveSupport::TestCase end def test_wiki_links_after_empty - assert_markup_parsed_as(%{\n

This is a wikilink\n

This is a wikilink?.

}, "\n\nThis is a [[wikilink]].") end @@ -55,7 +55,7 @@ class PageRendererTest < ActiveSupport::TestCase "would be My Way " + "" + "sin(x)" + - " in kinda " + + " in kinda " + "That Way in " + "His Way? " + %{though My Way OverThere \342\200\223 see } + @@ -164,7 +164,7 @@ END_THM %{
sin} + %{(x)} + - %{} + + %{} + %{\\sin(x) \\begin{svg}<svg/>\\end{svg}
}, "$$\\sin(x) \\begin{svg}\\end{svg}$$") @@ -601,7 +601,7 @@ END_THM # currently, upper case HTML elements are not allowed assert_markup_parsed_as( - "

This <IMG SRC='http://hobix.com/sample.jpg' alt=''/> is an inline image link.

", + "

This <IMG SRC='http://hobix.com/sample.jpg' alt=''></IMG> is an inline image link.

", 'This is an inline image link.') end @@ -659,7 +659,7 @@ END_THM "My Way " + "" + "sin(x)" + - " in kinda " + + " in kinda " + "That Way in " + "His Way though " + %{My Way OverThere \342\200\223 see } + diff --git a/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb b/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb index b5709a4c..80b5f01c 100644 --- a/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb +++ b/vendor/plugins/maruku/lib/maruku/output/s5/to_s5.rb @@ -107,14 +107,14 @@ require 'maruku/string_utils' end if (content_only) - xml = body.to_xml(:indent => (context[:indent] || 2), :save_with => 2 ) + xml = body.to_xml(:indent => (context[:indent] || 2), :save_with => 18 ) else doc2 = Nokogiri::XML::Document.parse("
"+S5_external+"
") doc2.root.children.each{ |child| head << child } add_css_to(head) - xml = html.to_xml(:indent => (context[:indent] || 2), :save_with => 2 ) + xml = html.to_xml(:indent => (context[:indent] || 2), :save_with => 18 ) Xhtml11_mathml2_svg11 + xml end end diff --git a/vendor/plugins/maruku/lib/maruku/output/to_html.rb b/vendor/plugins/maruku/lib/maruku/output/to_html.rb index 919d0271..7b55e760 100644 --- a/vendor/plugins/maruku/lib/maruku/output/to_html.rb +++ b/vendor/plugins/maruku/lib/maruku/output/to_html.rb @@ -46,7 +46,7 @@ module MaRuKu; module Out; module HTML d.root << render_footnotes end - xml = d.to_xml(:indent => (context[:indent] || 2), :save_with => 2 ) + xml = d.to_xml(:indent => (context[:indent] || 2), :save_with => 18 ) xml.gsub!(/\A\s*|\s*<\/dummy>\s*\Z|\A/,'') xml @@ -59,7 +59,7 @@ module MaRuKu; module Out; module HTML doc = to_html_document_tree xml = "" - xml = doc.to_xml(:indent => (context[:indent] || 2), :save_with => 2 ) + xml = doc.to_xml(:indent => (context[:indent] || 2), :save_with => 18 ) Xhtml11_mathml2_svg11 + xml end diff --git a/vendor/plugins/maruku/spec/block_docs/alt.md b/vendor/plugins/maruku/spec/block_docs/alt.md index bf4e90db..0314d6ed 100644 --- a/vendor/plugins/maruku/spec/block_docs/alt.md +++ b/vendor/plugins/maruku/spec/block_docs/alt.md @@ -8,7 +8,7 @@ Write a comment here *** Output of inspect *** md_el(:document,[md_par([md_im_image(["bar"], "/foo.jpg", nil)])],{},[]) *** Output of to_html *** -

bar

+

bar

*** Output of to_latex *** *** Output of to_md *** diff --git a/vendor/plugins/maruku/spec/block_docs/footnotes.md b/vendor/plugins/maruku/spec/block_docs/footnotes.md index 3fd57bec..c6cdd1ac 100644 --- a/vendor/plugins/maruku/spec/block_docs/footnotes.md +++ b/vendor/plugins/maruku/spec/block_docs/footnotes.md @@ -57,7 +57,7 @@ md_el(:document,[

That’s some text with a footnote 1 and another 2 and another 3.

This is not a footnote.

-

  1. +

    1. And that’s the footnote. This is second sentence (same paragraph).

    2. This is the very long one.

      diff --git a/vendor/plugins/maruku/spec/block_docs/hrule.md b/vendor/plugins/maruku/spec/block_docs/hrule.md index 8cc1f19d..5321c502 100644 --- a/vendor/plugins/maruku/spec/block_docs/hrule.md +++ b/vendor/plugins/maruku/spec/block_docs/hrule.md @@ -22,7 +22,7 @@ md_el(:document,[ md_el(:hrule,[],{},[]) ],{},[]) *** Output of to_html *** -




      +




      *** Output of to_latex *** \vspace{.5em} \hrule \vspace{.5em} diff --git a/vendor/plugins/maruku/spec/block_docs/html2.md b/vendor/plugins/maruku/spec/block_docs/html2.md index 5bb70312..114f6710 100644 --- a/vendor/plugins/maruku/spec/block_docs/html2.md +++ b/vendor/plugins/maruku/spec/block_docs/html2.md @@ -12,8 +12,8 @@ md_el(:document,[ md_html("
      ") ],{},[]) *** Output of to_html *** -

      One

      123

      -
      +

      One

      123

      +
      *** Output of to_latex *** One 123 *** Output of to_md *** diff --git a/vendor/plugins/maruku/spec/block_docs/html4.md b/vendor/plugins/maruku/spec/block_docs/html4.md index 9a25d280..0632991e 100644 --- a/vendor/plugins/maruku/spec/block_docs/html4.md +++ b/vendor/plugins/maruku/spec/block_docs/html4.md @@ -15,7 +15,7 @@ md_el(:document,[ ],{},[]) *** Output of to_html ***
      - +
      *** Output of to_latex *** diff --git a/vendor/plugins/maruku/spec/block_docs/html5.md b/vendor/plugins/maruku/spec/block_docs/html5.md index 253e17f8..7baa4b35 100644 --- a/vendor/plugins/maruku/spec/block_docs/html5.md +++ b/vendor/plugins/maruku/spec/block_docs/html5.md @@ -13,7 +13,7 @@ md_el(:document,[ ],{},[]) *** Output of to_html ***
      - Aperitif + Aperitif
      *** Output of to_latex *** diff --git a/vendor/plugins/maruku/spec/block_docs/ie.md b/vendor/plugins/maruku/spec/block_docs/ie.md index 935ef2ce..ef3c0e16 100644 --- a/vendor/plugins/maruku/spec/block_docs/ie.md +++ b/vendor/plugins/maruku/spec/block_docs/ie.md @@ -31,11 +31,11 @@ md_el(:document,[
      <p>here's an apostrophe & a quote "</p>
      -
      <p>here's an apostrophe & a quote "</p>
      +
      <p>here's an apostrophe & a quote "</p>
      -
      <p>here's an apostrophe & a quote "</p>
      +
      <p>here's an apostrophe & a quote "</p>
      -
      <p>here's an apostrophe & a quote "</p>
      +
      <p>here's an apostrophe & a quote "</p>
      *** Output of to_latex *** {\colorbox[rgb]{1.00,0.93,1.00}{\tt \char60p\char62here\char39s~an~apostrophe~\char38~a~quote~\char34\char60\char47p\char62}} diff --git a/vendor/plugins/maruku/spec/block_docs/images.md b/vendor/plugins/maruku/spec/block_docs/images.md index 3fb25f8a..e3122974 100644 --- a/vendor/plugins/maruku/spec/block_docs/images.md +++ b/vendor/plugins/maruku/spec/block_docs/images.md @@ -52,15 +52,15 @@ md_el(:document,[ md_ref_def("css2", "http://jigsaw.w3.org/css-validator/images/vcss", {:title=>"Optional title attribute"}) ],{},[]) *** Output of to_html *** -

      This page does not utilize Cascading Style Sheets

      +

      This page does not utilize Cascading Style Sheets

      -

      Please mouseover to see the title: Cascading Style Sheets

      +

      Please mouseover to see the title: Cascading Style Sheets

      -

      Please mouseover to see the title: Cascading Style Sheets

      +

      Please mouseover to see the title: Cascading Style Sheets

      -

      I’ll say it one more time: this page does not use Cascading Style Sheets

      +

      I’ll say it one more time: this page does not use Cascading Style Sheets

      -

      This is double size: Cascading Style Sheets

      +

      This is double size: Cascading Style Sheets

      *** Output of to_latex *** This page does not utilize diff --git a/vendor/plugins/maruku/spec/block_docs/images2.md b/vendor/plugins/maruku/spec/block_docs/images2.md index 77bace62..2df9f01b 100644 --- a/vendor/plugins/maruku/spec/block_docs/images2.md +++ b/vendor/plugins/maruku/spec/block_docs/images2.md @@ -16,9 +16,9 @@ md_el(:document,[ md_ref_def("image", "image.jpg", {:title=>nil}) ],{},[]) *** Output of to_html *** -

      This is an image.

      +

      This is an image.

      -

      This is an image.

      +

      This is an image.

      *** Output of to_latex *** This is an . diff --git a/vendor/plugins/maruku/spec/block_docs/inline_html.md b/vendor/plugins/maruku/spec/block_docs/inline_html.md index 39d9dd5d..2c155c7b 100644 --- a/vendor/plugins/maruku/spec/block_docs/inline_html.md +++ b/vendor/plugins/maruku/spec/block_docs/inline_html.md @@ -73,12 +73,12 @@ md_el(:document,[
      <img src="http://jigsaw.w3.org/css-validator/images/vcss"/>
      -

      Result on span:

      +

      Result on span:

      Result alone:

      - +

      Without closing:

      -
      +

      This is

      diff --git a/vendor/plugins/maruku/spec/block_docs/lists_after_paragraph.md b/vendor/plugins/maruku/spec/block_docs/lists_after_paragraph.md index 0c5f648e..2e8c9fe1 100644 --- a/vendor/plugins/maruku/spec/block_docs/lists_after_paragraph.md +++ b/vendor/plugins/maruku/spec/block_docs/lists_after_paragraph.md @@ -102,9 +102,9 @@ md_el(:document,[

      Paragraph (1 space after), list with no space: * ciao

      -

      Paragraph (2 spaces after), list with no space:
      * ciao

      +

      Paragraph (2 spaces after), list with no space:
      * ciao

      -

      Paragraph (3 spaces after), list with no space:
      * ciao

      +

      Paragraph (3 spaces after), list with no space:
      * ciao

      Paragraph with block quote:

      @@ -120,7 +120,7 @@ md_el(:document,[

      header

      -

      Paragraph with html after

      +

      Paragraph with html after

      Paragraph with html after, indented: Emphasis

      diff --git a/vendor/plugins/maruku/spec/block_docs/loss.md b/vendor/plugins/maruku/spec/block_docs/loss.md index 08cb73e1..14bf60ba 100644 --- a/vendor/plugins/maruku/spec/block_docs/loss.md +++ b/vendor/plugins/maruku/spec/block_docs/loss.md @@ -7,7 +7,7 @@ Write a comment here *** Output of inspect *** md_el(:document,[md_html("
      ")],{},[]) *** Output of to_html *** -
      +
      *** Output of to_latex *** *** Output of to_md *** diff --git a/vendor/plugins/maruku/spec/block_docs/notyet/triggering.md b/vendor/plugins/maruku/spec/block_docs/notyet/triggering.md index 0c04644b..160f04ae 100644 --- a/vendor/plugins/maruku/spec/block_docs/notyet/triggering.md +++ b/vendor/plugins/maruku/spec/block_docs/notyet/triggering.md @@ -74,9 +74,9 @@ md_el(:document,[

      Paragraph (1 space after), list with no space: * ciao

      -

      Paragraph (2 spaces after), list with no space:
      * ciao

      +

      Paragraph (2 spaces after), list with no space:
      * ciao

      -

      Paragraph (3 spaces after), list with no space:
      * ciao

      +

      Paragraph (3 spaces after), list with no space:
      * ciao

      Paragraph with block quote:

      diff --git a/vendor/plugins/maruku/spec/block_docs/paragraphs.md b/vendor/plugins/maruku/spec/block_docs/paragraphs.md index a858b1c1..db9e7f77 100644 --- a/vendor/plugins/maruku/spec/block_docs/paragraphs.md +++ b/vendor/plugins/maruku/spec/block_docs/paragraphs.md @@ -28,7 +28,7 @@ md_el(:document,[

      Paragraph 2

      -

      Paragraph 3 Paragraph 4 Paragraph Br->
      Paragraph 5

      +

      Paragraph 3 Paragraph 4 Paragraph Br->
      Paragraph 5

      *** Output of to_latex *** Paragraph 1 diff --git a/vendor/plugins/maruku/spec/block_docs/pending/empty_cells.md b/vendor/plugins/maruku/spec/block_docs/pending/empty_cells.md index 798d8ca9..61fd62a4 100644 --- a/vendor/plugins/maruku/spec/block_docs/pending/empty_cells.md +++ b/vendor/plugins/maruku/spec/block_docs/pending/empty_cells.md @@ -21,8 +21,8 @@ md_el(:document,[ ],{:align=>[:left, :left, :left]},[]) ],{},[]) *** Output of to_html *** - - +
      12
      AX
      BX
      +
      12
      AX
      BX
      *** Output of to_latex *** \begin{tabular}{l|l|l} diff --git a/vendor/plugins/maruku/spec/block_docs/syntax_hl.md b/vendor/plugins/maruku/spec/block_docs/syntax_hl.md index 7e6bfe8e..52d804c6 100644 --- a/vendor/plugins/maruku/spec/block_docs/syntax_hl.md +++ b/vendor/plugins/maruku/spec/block_docs/syntax_hl.md @@ -31,7 +31,7 @@ puts Maruku.new($stdin).to_html

      This is ruby code:

      -
      require 'maruku'
      +
      require 'maruku'
      puts Maruku.new($stdin).to_html
      *** Output of to_latex *** diff --git a/vendor/plugins/maruku/spec/block_docs/wrapping.md b/vendor/plugins/maruku/spec/block_docs/wrapping.md index 8b6c5333..b5d952d6 100644 --- a/vendor/plugins/maruku/spec/block_docs/wrapping.md +++ b/vendor/plugins/maruku/spec/block_docs/wrapping.md @@ -29,10 +29,10 @@ md_el(:document,[ ],{},[]) ],{},[]) *** Output of to_html *** -

      Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Break:
      Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet.

      +

      Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Break:
      Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet.

        -
      • Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet Lorem ipsum Break:
        Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet
      • +
      • Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet Lorem ipsum Break:
        Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet
      • Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet