[kramdown-users] Proposal: block level image tag

Eric Sunshine sunshine at sunshineco.com
Thu Jul 15 16:31:34 EDT 2010

On 07/15/2010 10:24 AM, Thomas Leitner wrote:
> You are right,<img/>  tags are only allowed inside elements with the
> Flow/Inline content model and<body>  has the Block content model. Since this
> was basically a request on the side of LaTeX conversion, what about
> just leaving nearly everything as-is and just recognizing "block level"
> image tags only in the LaTeX converter, i.e.:
>      ![caption](foo.png)
>      [![caption](foo.png)](http://www.example.com)
> gets converted to HTML like this (no difference to current output):
>      <p><img alt="caption" src="foo.png" /></p>
>      <p><a href="http://www.example.com"><img alt="caption" src="foo.png" /></a></p>

This probably is the correct approach, and certainly is simplest.

The one thing I liked about the idea of the automatically-generated 
<div> wrapper was that raw <div>s typically are unstyled (no 
margin/padding) wheres raw <p>s typically have margin/padding set which 
might "interfere" with desired styling of the enclosed <img/>. The <div> 
wrapper would make it very convenient to interleave blocks of text with 
the occasional image, which is quite common on websites and in printed 
papers. It is, of course, still possible to interleave images with text 
blocks without interference from the default paragraph styling either by 
overriding the styling:


or via manual <div> wrapper:

     <div markdown="1">

however, both approaches are rather verbose and ugly for the common case 
of interleaving text bocks and images. On the other hand, the added 
implementation complexity of auto-wrapping the stand-alone image in a 
<div> may be unwarranted, especially as additional special-cases (such 
as the clickable stand-alone image) come to light.

Regarding the situation of a stand-alone image in HTML-to-markdown 
conversion: The HTML on which I tested was _old_, so it is not 
unexpected that some manual cleanup of the generated Markdown would be 
needed. Also, unlike Markdown-to-HTML, the reverse HTML-to-Markdown 
conversion is likely performed only once in order to place the document 
in a more maintainable format (Markdown), thus the possible one-time 
manual cleanup may not be particularly onerous.

-- ES

More information about the kramdown-users mailing list