我正在爲WordPress提供一個簡單的小部件,用於從Twitter提供的RSS源中提取最新的推文。這個小部件解析發佈在推文上的任何鏈接,它還解析提及(即:@用戶名)和趨勢主題(即:#現在)。對於這三種情況,它會創建指向某些Twitter功能的鏈接。XHTML 1.1文檔中的嵌套超鏈接
例如:
"Hi @UserA, check out the song Foo from FooBar that I'm listening,
it's awesome. #nowplaying"
它將解析成這樣:
Hi <a href="http://twitter.com/UserA">@UserA</a>, check out the song
Foo from FooBar that I'm listening, it's awesome.
<a href="http://twitter.com/#search?q=nowplaying">#nowplaying</a>
現在,現在我需要一個全球性的鏈接添加到整個郵件,就像這樣:
<a href="http://twitter.com/UserA/statuses/1234567890">
Hi <a href="http://twitter.com/UserA">@UserA</a>, check out the song
Foo from FooBar that I'm listening, it's awesome.
<a href="http://twitter.com/#search?q=nowplaying">#nowplaying</a>
</a>
但是這段代碼並沒有被驗證,反正它也不起作用(瀏覽器似乎不知道該怎麼辦)。
任何建議如何解決這個問題?