Avoiding <div>text -> <div><p>text

21 views
Skip to first unread message

Jack Bates

unread,
Mar 8, 2016, 12:28:02 PM3/8/16
to kramdow...@googlegroups.com
I'd like to add a little kramdown sugar to some existing HTML pages.
They're mostly HTML, so I'd rather not universally transform
<div>text</div> to <div><p>text</p></div> but I do want to use other
kramdown syntax inside <div> tags, e.g. <div>[linkid]</div>.
Is there a good way to achieve this?

What I'm trying now: I use the following to configure :span content
model for all HTML (except :raw elements):

HTML_CONTENT_MODEL_BLOCK.each { |i| HTML_CONTENT_MODEL[i] = :span }
HTML_BLOCK_ELEMENTS = []

Without the second line, if my input does contain <div><p>text</p></div>
kramdown complains: Found block HTML tag 'p' in span-level text

Does what I'm doing make sense? Is there a better way?

Thomas Leitner

unread,
Mar 13, 2016, 6:46:18 AM3/13/16
to kramdow...@googlegroups.com
If this works for you, go for it. Note, however, that kramdown was not
designed to be used in that way.

You could also modify your document to use the "markdown" attribute,
like this:

<div markdown="span">[linkid]</div>

-- Thomas
Reply all
Reply to author
Forward
0 new messages