I noticed that if a div element is not followed by a newline then TW generates following HTML.
Example 1-a
TW markup:
<div>
eg 1
</div>
produces following HTML:
<p><div>
eg 1
</div></p>
Notice that div is surrounded by p.
Example 1-b
But if div is followed a by a newline like so in the following TW markup
<div>
eg 2
</div>
produces following HTML:
<div><p>eg 2
</p></div>
Notice, now div has p inside its body.
Example 2-a
Here is a macro example,
\define test()
<$transclude mode="block" tiddler="pdf-tiddler" />
\end
<<test>>
Produces this HTML:
<p><embed src="https://example.com/file.pdf"></p>
Notice how embed is surrounded by p.
Example 2-b
But if I insert a newline before \end like so
\define test()
<$transclude mode="block" tiddler="pdf-tiddler" />
\end
<<test>>
Produces this HTML:
<embed src="https://example.com/file.pdf">
p element disappears.
Example 3
I noticed similar issue in template. If a <$transclude mode="block" tiddler="pdf-tiddler" /> is preceded with two blank lines that the embed is not surrounded by p, otherwise it is surrounded by p.
Question
How does TW interpret newline when parsing?