2011-06-14 33 views
1

我使用PHP Markdown(版本1.0.1n,更新2009年10月)顯示保存在降價格式的數據庫中的文本。我遇到了一個奇怪的問題,它將每個條目的最後一部分標記爲H3。但是,當我搜索markdown.php文件時,沒有H3的單個實例。PHP降價的內容最後一塊標註爲H3

這裏是從我的數據庫的文字兩個部分組成:

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. 

在這其中,它被正確標記的李項目,但最終李裏面它標記的實際文本爲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. 

在這一個中,以Diane Oshin開頭的整個段落被標記爲H3。

這裏是非常奇怪的事情:當我做了查看源代碼,兩者都被正確標記;只有在使用Inspect Element時纔會看到H3。然而,它在實際顯示明顯,正在應用的H3標籤:

例如1 example 1

例如2 example 2

誰能幫助我嗎?

更新

每下方的評論,我看了用於h標籤的實例。我發現了這些功能,但不知道這是否是可能導致問題的原因。它們是整個文件中唯一可以創建任何類型標題標籤的地方。

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"; 
    } 
+1

你試過獲得項目的開發版本?你可以得到它[通過混帳(http://git.michelf.com/php-markdown/)。 – Blender 2011-06-14 15:56:25

+0

尋找一個作爲'3'的實例可能會根據解析器狀態添加。 – hakre 2011-06-14 15:59:32

+0

@hakre - 我正在更新原始帖子; H標籤很奇怪... – EmmyS 2011-06-14 16:15:14

回答

1

我無法重現你與你已經給出的版本描述:

<?php 
include(__DIR__.'/php-markdown/markdown.php'); 


$testText = '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. 
'; 

$resultText = Markdown($testText); 

var_dump($resultText); 

輸出看起來相當正如你所預料它

string(649) "<p>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:</p> 

<ul> 
<li><p>The prioritization of shopping media for CPG brands.</p></li> 
<li><p>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.</p></li> 
<li><p>How CPG brands are leveraging real-time data from shopping media to capture consumer insights and market trends.</p></li> 
</ul> 
" 

我認爲別的東西在數據進入降價解析器之前或之後篡改數據。但基於這些數據,降價解析器不會創建<h3>標籤。你必須尋找別的地方:(

+0

感謝您花時間做到這一點。我將不得不搜索我們的樣式表,看看是否有什麼造成這種情況。 – EmmyS 2011-06-14 18:48:33

+0

我不知道你是否還在看這個,但是我拿掉了Markdown的電話,只是打印了正文,並沒有奇怪的格式。所以它必須是Markdown函數中的一部分,不是嗎? – EmmyS 2011-06-14 21:04:41

+0

不在我的電腦上,它的功能完美。查看我發佈的代碼。 – hakre 2011-06-14 21:12:24