I’m using PHP Markdown (version 1.0.1n, updated October 2009) to display text saved to a database in markdown format. I’m running into a strange issue where it’s tagging the last chunk of every entry as an H3. When I search the markdown.php file, though, there isn’t a single instance of H3.
Here are two pieces of text from my database:
Since its launch, major CPG brands, endemic as well as non-endemic, have flocked to retail websites to reach consumers deep in the purchase funnel through shopping media. In this session, you will hear about:
- The prioritization of shopping media for CPG brands.
- A case study of brands on Target.com on how this retailer (and others) have introduced a new channel for brand marketers to engage consumers where they are making the majority of purchase decisions: online.
- How CPG brands are leveraging real-time data from shopping media to capture consumer insights and market trends.
In this one, it is tagging the LI items correctly, but inside the final LI it’s tagging the actual text as H3.
Beyond the actual money she saves, this consumer is both empowered and psychologically gratified by getting the best value on her everyday purchases. It is essential for both marketers and retailers to focus on what motivates and activates this consumer.
Diane Oshin will share insights on what influences her shopping behavior and then identify specific tools that activate her to buy.
In this one, the entire paragraph starting with Diane Oshin is tagged as an H3.
Here’s the really odd thing: when I do a view source, both of them are tagged correctly; it’s only when using Inspect Element that I see the H3. However, it’s obvious in the actual display that the H3 tag is being applied:
example 1

example 2

Can anyone help me out?
update
Per a comment below, I looked for instances of H tags. I found these functions, but don’t know if this is what could be causing the issue or not. They are the only place in the entire file that appears to be creating a header tag of any kind.
function doHeaders($text) {
# Setext-style headers:
# Header 1
# ========
#
# Header 2
# --------
#
$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
array(&$this, '_doHeaders_callback_setext'), $text);
# atx-style headers:
# # Header 1
# ## Header 2
# ## Header 2 with closing hashes ##
# ...
# ###### Header 6
#
$text = preg_replace_callback('{
^(\#{1,6}) # $1 = string of #\'s
[ ]*
(.+?) # $2 = Header text
[ ]*
\#* # optional closing #\'s (not counted)
\n+
}xm',
array(&$this, '_doHeaders_callback_atx'), $text);
return $text;
}
function _doHeaders_callback_setext($matches) {
# Terrible hack to check we haven't found an empty list item.
if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
return $matches[0];
$level = $matches[2]{0} == '=' ? 1 : 2;
$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
return "\n" . $this->hashBlock($block) . "\n\n";
}
function _doHeaders_callback_atx($matches) {
$level = strlen($matches[1]);
$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
return "\n" . $this->hashBlock($block) . "\n\n";
}
I could not reproduce what you describe with the version you’ve been given:
The output looks fairly as you might expect it
I assume something else tampering the data before it get’s into the markdown parser or afterwards. But based on the data, the markdown parser does not create the
<h3>tags. You must look somewhere else 🙁