Search code examples
markdownhtmlword-wrap

Markdown: prevent paragraph tag being wrapped around standard HTML span tag


I want to mix standard HTML and Markdown. I have a paragraph written with Markdown, followed by an HTML <span> element.

The problem is: if I don't put return after the paragraph: the <span> will be immediately after the text within the paragraph's <p> tag:

<p>Some text  
<span>My span</span>  
</p>

However if I do put return after the paragraph (written in Markdown), the <span> alone will be wrapped around in <p> tags, like so:

<p>Some text</p>  
<p><span>My span</span></p>

What I want is simply this:

<p>Some text</p><span>My span</span>

Sorry if I am overlooking something very obvious, I'm very tired. Thanks!

(I'm using Kramdown for conversion if that's any help)


Solution

  • Nevermind, I've figured it out! :) So, in Kramdown, you can use some kind of an escape, that prevent parsing what's inside, but you have to be careful to leave blank lines both before and after:

    <p>Some text</p>  
    return  
    {::nomarkdown}  
    <span>My Span</span>  
    {:/}  
    return  
    ...