maruku icon indicating copy to clipboard operation
maruku copied to clipboard

Support HTML output

Open bhollis opened this issue 11 years ago • 6 comments

Right now Maruku only produces XHTML output, but it should be able to produce HTML output instead.

bhollis avatar Sep 16 '12 00:09 bhollis

This would fix the self-closing div/iframe issues if I'm not mistaken?

alexmarchant avatar Feb 24 '13 08:02 alexmarchant

Hi Alex,

Could you explain the "self-closing div/iframe issues"? I'm not aware of them, and I don't think we have any tests for problems around divs or iframes, so if you have any examples I can make sure to fix that.

bhollis avatar Feb 25 '13 05:02 bhollis

If the input says <div></div>, Nokogiri serializes this to <div/>. Which is perfectly equivalent, when interpreted as XHTM, but means something radically different (an opening div tag, with no corresponding closing tag), when interpreted as HTML.

Ideally, an HTML5-aware serializer would be smarter about this (knowing that only "void" elements can have self-closing tags).

  • <img/> is perfectly valid HTML5, and means the same thing as it does in XHTML
  • <iframe/> is not valid HTML5, and should be written as <iframe></iframe> (which will be interpreted correctly, either in HTML or XHTML).

distler avatar Feb 25 '13 06:02 distler

inline-html = '<div></div>
<iframe src="http://www.google.com"></iframe>'

 => "<div></div>\n<iframe src=\"http://www.google.com\"></iframe>" 

Maruku.new(inline-html).to_html

 => "<div /><iframe src='http://www.google.com' />"

I believe self closing div's and several other elements are valid XHTML but not HTML and this causes issues in the browsers I've used. Adding empty space between the elements (i.e. <div> </div>) fixes the problem.

alexmarchant avatar Feb 25 '13 06:02 alexmarchant

OK, in that case yes, when HTML output is added, it should support this (by virtue of Nokogiri doing the right thing).

bhollis avatar Feb 25 '13 16:02 bhollis

+1. The current Maruku (REXML, really) also chokes on html attributes without values.

<span data-myattribute>I cause an `malformed XML: missing tag start` REXML error</span>

robwierzbowski avatar Jul 02 '13 16:07 robwierzbowski