Better text/html serialization
For the Andrew Staceys of this world: deal with empty element in a more text/html-friendly fashion.
This commit is contained in:
parent
27ad6ff2a8
commit
2d303d54a0
|
@ -45,7 +45,7 @@ class PageRendererTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_wiki_links_after_empty
|
def test_wiki_links_after_empty
|
||||||
assert_markup_parsed_as(%{<code/>\n<p>This is a <span class='newWikiWord'>wikilink<a href=} +
|
assert_markup_parsed_as(%{<code></code>\n<p>This is a <span class='newWikiWord'>wikilink<a href=} +
|
||||||
%{'../show/wikilink'>?</a></span>.</p>},
|
%{'../show/wikilink'>?</a></span>.</p>},
|
||||||
"<code></code>\n\nThis is a [[wikilink]].")
|
"<code></code>\n\nThis is a [[wikilink]].")
|
||||||
end
|
end
|
||||||
|
@ -55,7 +55,7 @@ class PageRendererTest < ActiveSupport::TestCase
|
||||||
"would be <a class='existingWikiWord' href='../show/MyWay'>My Way</a> " +
|
"would be <a class='existingWikiWord' href='../show/MyWay'>My Way</a> " +
|
||||||
"<math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>" +
|
"<math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>" +
|
||||||
"<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics>" +
|
"<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics>" +
|
||||||
"<annotation-xml encoding='SVG1.1'><svg/></annotation-xml></semantics></math> in kinda " +
|
"<annotation-xml encoding='SVG1.1'><svg></svg></annotation-xml></semantics></math> in kinda " +
|
||||||
"<a class='existingWikiWord' href='../show/ThatWay'>That Way</a> in " +
|
"<a class='existingWikiWord' href='../show/ThatWay'>That Way</a> in " +
|
||||||
"<span class='newWikiWord'>His Way<a href='../show/HisWay'>?</a></span> " +
|
"<span class='newWikiWord'>His Way<a href='../show/HisWay'>?</a></span> " +
|
||||||
%{though <a class='existingWikiWord' href='../show/MyWay'>My Way</a> OverThere \342\200\223 see } +
|
%{though <a class='existingWikiWord' href='../show/MyWay'>My Way</a> OverThere \342\200\223 see } +
|
||||||
|
@ -164,7 +164,7 @@ END_THM
|
||||||
%{<div class='maruku-equation'><math class='maruku-mathml' display='block' } +
|
%{<div class='maruku-equation'><math class='maruku-mathml' display='block' } +
|
||||||
%{xmlns='http://www.w3.org/1998/Math/MathML'><mi>sin</mi><mo stretchy='false'>} +
|
%{xmlns='http://www.w3.org/1998/Math/MathML'><mi>sin</mi><mo stretchy='false'>} +
|
||||||
%{(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics><annotation-xml encoding='SVG1.1'>} +
|
%{(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics><annotation-xml encoding='SVG1.1'>} +
|
||||||
%{<svg/></annotation-xml></semantics></math><span class='maruku-eq-tex'><code style='display: none;'>} +
|
%{<svg></svg></annotation-xml></semantics></math><span class='maruku-eq-tex'><code style='display: none;'>} +
|
||||||
%{\\sin(x) \\begin{svg}<svg/>\\end{svg}</code></span></div>},
|
%{\\sin(x) \\begin{svg}<svg/>\\end{svg}</code></span></div>},
|
||||||
"$$\\sin(x) \\begin{svg}<svg/>\\end{svg}$$")
|
"$$\\sin(x) \\begin{svg}<svg/>\\end{svg}$$")
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ END_THM
|
||||||
|
|
||||||
# currently, upper case HTML elements are not allowed
|
# currently, upper case HTML elements are not allowed
|
||||||
assert_markup_parsed_as(
|
assert_markup_parsed_as(
|
||||||
"<p>This <IMG SRC='http://hobix.com/sample.jpg' alt=''/> is an inline image link.</p>",
|
"<p>This <IMG SRC='http://hobix.com/sample.jpg' alt=''></IMG> is an inline image link.</p>",
|
||||||
'This <IMG SRC="http://hobix.com/sample.jpg" alt="" /> is an inline image link.')
|
'This <IMG SRC="http://hobix.com/sample.jpg" alt="" /> is an inline image link.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ END_THM
|
||||||
"<a class='existingWikiWord' href='MyWay.html'>My Way</a> " +
|
"<a class='existingWikiWord' href='MyWay.html'>My Way</a> " +
|
||||||
"<math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>" +
|
"<math class='maruku-mathml' display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>" +
|
||||||
"<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics>" +
|
"<mi>sin</mi><mo stretchy='false'>(</mo><mi>x</mi><mo stretchy='false'>)</mo><semantics>" +
|
||||||
"<annotation-xml encoding='SVG1.1'><svg/></annotation-xml></semantics></math> in kinda " +
|
"<annotation-xml encoding='SVG1.1'><svg></svg></annotation-xml></semantics></math> in kinda " +
|
||||||
"<a class='existingWikiWord' href='ThatWay.html'>That Way</a> in " +
|
"<a class='existingWikiWord' href='ThatWay.html'>That Way</a> in " +
|
||||||
"<span class='newWikiWord'>His Way</span> though " +
|
"<span class='newWikiWord'>His Way</span> though " +
|
||||||
%{<a class='existingWikiWord' href='MyWay.html'>My Way</a> OverThere \342\200\223 see } +
|
%{<a class='existingWikiWord' href='MyWay.html'>My Way</a> OverThere \342\200\223 see } +
|
||||||
|
|
|
@ -107,14 +107,14 @@ require 'maruku/string_utils'
|
||||||
end
|
end
|
||||||
|
|
||||||
if (content_only)
|
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
|
else
|
||||||
doc2 = Nokogiri::XML::Document.parse("<div>"+S5_external+"</div>")
|
doc2 = Nokogiri::XML::Document.parse("<div>"+S5_external+"</div>")
|
||||||
doc2.root.children.each{ |child| head << child }
|
doc2.root.children.each{ |child| head << child }
|
||||||
|
|
||||||
add_css_to(head)
|
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
|
Xhtml11_mathml2_svg11 + xml
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ module MaRuKu; module Out; module HTML
|
||||||
d.root << render_footnotes
|
d.root << render_footnotes
|
||||||
end
|
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<dummy>\s*|\s*<\/dummy>\s*\Z|\A<dummy\s*\/>/,'')
|
xml.gsub!(/\A<dummy>\s*|\s*<\/dummy>\s*\Z|\A<dummy\s*\/>/,'')
|
||||||
xml
|
xml
|
||||||
|
@ -59,7 +59,7 @@ module MaRuKu; module Out; module HTML
|
||||||
doc = to_html_document_tree
|
doc = to_html_document_tree
|
||||||
xml = ""
|
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
|
Xhtml11_mathml2_svg11 + xml
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,8 +12,8 @@ md_el(:document,[
|
||||||
md_html("<div></div>")
|
md_html("<div></div>")
|
||||||
],{},[])
|
],{},[])
|
||||||
*** Output of to_html ***
|
*** Output of to_html ***
|
||||||
<p>One <div/>123</p>
|
<p>One <div></div>123</p>
|
||||||
<div/>
|
<div></div>
|
||||||
*** Output of to_latex ***
|
*** Output of to_latex ***
|
||||||
One 123
|
One 123
|
||||||
*** Output of to_md ***
|
*** Output of to_md ***
|
||||||
|
|
6
vendor/plugins/maruku/spec/block_docs/ie.md
vendored
6
vendor/plugins/maruku/spec/block_docs/ie.md
vendored
|
@ -31,11 +31,11 @@ md_el(:document,[
|
||||||
|
|
||||||
<pre><code><p>here's an apostrophe & a quote "</p></code></pre>
|
<pre><code><p>here's an apostrophe & a quote "</p></code></pre>
|
||||||
|
|
||||||
<pre class="xml"><code lang="xml"><span class="punct"><</span><span class="tag">p</span><span class="punct">></span>here's an apostrophe & a quote "<span class="punct"></</span><span class="tag">p</span><span class="punct">></span></code></pre>
|
<pre class="xml"><code lang="xml" xml:lang="xml"><span class="punct"><</span><span class="tag">p</span><span class="punct">></span>here's an apostrophe & a quote "<span class="punct"></</span><span class="tag">p</span><span class="punct">></span></code></pre>
|
||||||
|
|
||||||
<pre class="not_supported"><code lang="not_supported"><p>here's an apostrophe & a quote "</p></code></pre>
|
<pre class="not_supported"><code lang="not_supported" xml:lang="not_supported"><p>here's an apostrophe & a quote "</p></code></pre>
|
||||||
|
|
||||||
<pre class="xml"><code lang="xml"><span class="punct"><</span><span class="tag">p</span><span class="punct">></span>here's an apostrophe & a quote "<span class="punct"></</span><span class="tag">p</span><span class="punct">></span></code></pre>
|
<pre class="xml"><code lang="xml" xml:lang="xml"><span class="punct"><</span><span class="tag">p</span><span class="punct">></span>here's an apostrophe & a quote "<span class="punct"></</span><span class="tag">p</span><span class="punct">></span></code></pre>
|
||||||
*** Output of to_latex ***
|
*** 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}}
|
{\colorbox[rgb]{1.00,0.93,1.00}{\tt \char60p\char62here\char39s~an~apostrophe~\char38~a~quote~\char34\char60\char47p\char62}}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ md_el(:document,[
|
||||||
|
|
||||||
<h2 id="header_2">header</h2>
|
<h2 id="header_2">header</h2>
|
||||||
|
|
||||||
<p>Paragraph with html after <div/></p>
|
<p>Paragraph with html after <div></div></p>
|
||||||
|
|
||||||
<p>Paragraph with html after, indented: <em>Emphasis</em></p>
|
<p>Paragraph with html after, indented: <em>Emphasis</em></p>
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ md_el(:document,[
|
||||||
],{:align=>[:left, :left, :left]},[])
|
],{:align=>[:left, :left, :left]},[])
|
||||||
],{},[])
|
],{},[])
|
||||||
*** Output of to_html ***
|
*** Output of to_html ***
|
||||||
<table><thead><tr><th/><th>1</th><th>2</th></tr></thead><tbody><tr><td style="text-align: left;">A</td><td style="text-align: left;">X</td><td style="text-align: left;"/></tr>
|
<table><thead><tr><th></th><th>1</th><th>2</th></tr></thead><tbody><tr><td style="text-align: left;">A</td><td style="text-align: left;">X</td><td style="text-align: left;"></td></tr>
|
||||||
<tr><td style="text-align: left;">B</td><td style="text-align: left;"/><td style="text-align: left;">X</td></tr>
|
<tr><td style="text-align: left;">B</td><td style="text-align: left;"></td><td style="text-align: left;">X</td></tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
*** Output of to_latex ***
|
*** Output of to_latex ***
|
||||||
\begin{tabular}{l|l|l}
|
\begin{tabular}{l|l|l}
|
||||||
|
|
|
@ -31,7 +31,7 @@ puts Maruku.new($stdin).to_html</code></pre>
|
||||||
|
|
||||||
<p>This is ruby code:</p>
|
<p>This is ruby code:</p>
|
||||||
|
|
||||||
<pre class="ruby"><code lang="ruby"><span class="ident">require</span> <span class="punct">'</span><span class="string">maruku</span><span class="punct">'</span></code></pre>
|
<pre class="ruby"><code lang="ruby" xml:lang="ruby"><span class="ident">require</span> <span class="punct">'</span><span class="string">maruku</span><span class="punct">'</span></code></pre>
|
||||||
|
|
||||||
<pre><code>puts Maruku.new($stdin).to_html</code></pre>
|
<pre><code>puts Maruku.new($stdin).to_html</code></pre>
|
||||||
*** Output of to_latex ***
|
*** Output of to_latex ***
|
||||||
|
|
Loading…
Reference in a new issue