[kramdown-users] getting kramdown not to wrap with p tags

Shawn Van Ittersum svicalifornia at gmail.com
Sun Mar 28 21:54:30 EDT 2010


Matt,

Markdown and kramdown both specify that whitespace delineates paragraphs, and I think it's safe to say that's a core rule of the syntax, upon which many of us depend.

If you don't want a paragraph around the image, do this:

test
<img ... />
test

If you want paragraph elements around "test" and "test," but not around the img, then I'd be curious to know more about your use case, as you would probably be better off using CSS than by having p's and img's as peer-level elements.

Shawn

On Sun, 28 Mar 2010 15:30:59 -0700, Matt Neuburg wrote:
> I'm having trouble figuring out how to tell kramdown not to wrap a paragraph
> with <p> tags.
> 
> For example, consider this input (in this email, "==" delimits the start and
> end of text input and is not a real set of characters):
> 
> ==
> test
> 
> <img src="hoho.png" />
> 
> test
> ==
> 
> The output is (ignoring whitespace):
> 
> <p>test</p>
> <p><img src="hoho.png" /></p>
> <p>test</p>
> 
> But that isn't what I want. I don't want the <img> tag wrapped in <p> tags.
> It is legal for an img tag to exist outside of a paragraph and that is what
> I want here.
> 
> I tried some workarounds but they don't work. In this particular example,
> one possibility is to trick kramdown into ignoring the paragraph containing
> the <img> tag by wrapping it in open and close <p> tags, like this:
> 
> ==
> test
> 
> <p></p><img src="hoho.png" /><p></p>
> 
> test
> ==
> 
> The hope is that the initial <p> tag will cause the whole paragraph to be
> ignored by kramdown (this trick does work with Markdown). Unfortunately, the
> output is:
> 
> <p>test</p>
> <p />
> <p><img src="hoho.png" /></p>
> <p>test</p>
> 
> So that didn't work (and the output makes no sense to me in relation to the
> input, but that's not important).
> 
> I feel sure that I'm missing something. The problem arises in several other
> cases where a tag is a legal stand-alone (<br> tags, for example).
> 
> m.
> 
> -- 
> matt neuburg, phd = matt at tidbits.com, http://www.tidbits.com/matt/
> pantes anthropoi tou eidenai oregontai phusei
> Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
> AppleScript: the Definitive Guide, 2nd edition
> http://www.tidbits.com/matt/default.html#applescriptthings
> Take Control of Exploring & Customizing Snow Leopard
> http://tinyurl.com/kufyy8
> RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
> TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
> 
> 
> 
> _______________________________________________
> kramdown-users mailing list
> kramdown-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/kramdown-users


More information about the kramdown-users mailing list