I’m using kramdown with static site generator Nanoc to generate HTML from Markdown.
By default, kramdown is generating Markdown double-spaces as XHTML-friendly <br /> instead of HTML5's <br>, so the HTML5 validator is “informing” about this:
Info: Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.
From line … (etc)
text_here.<br />
Is there a kramdown or Nanoc option/command to force <br> instead of <br /> for line breaks indicated by double-spaces at a line end?
Edit the html.rb file in (…)/gems/kramdown/
I found the location of the relevant code on line 267 of the HTML converter in:
"/usr/local/lib/ruby/gems/3.2.0/gems/kramdown-2.4.0/lib/kramdown/converter/html.rb" (my Ruby is Homebrew-installed)
and (sudo) edited
<br />to<br>with Micro (command-line editor:brew install micro) to preserve the file’s permissions and ownership.Then recompiled a Markdown file with double-space line breaks and am now seeing
<br>instead of<br />. Also did the same for other self-closing HTML5 tags (imgandhr) as well as the places where kramdown parses self-closing tags in raw HTML inside Markdown files - just replaced/>with>, carefully, and manually. Now getting nice HTML5 output that the validator likes.You can see the HTML converter on the kramdown GitHub repo.
However, I presume any update to the kramdown gem will overwrite it - so if anyone knows how to make this change permanent for a local kramdown gem, advice is welcome. See this post on the kramdown Google group