Commit 90e7ffc6 authored by Gregor Morrill's avatar Gregor Morrill

Improved rel-bookmark parsing.

Updated tests to avoid implied u-url, test existing class attribute, and more complex rel-bookmark.
parent b27dc8d5
......@@ -770,17 +770,15 @@ class Parser {
$children = array();
$dates = array();
foreach ( $this->xpath->query('.//a[@rel and @href]', $e) as $el )
// each rel-bookmark with an href attribute
foreach ( $this->xpath->query('.//a[contains(concat(" ",normalize-space(@rel)," ")," bookmark ") and @href]', $e) as $el )
{
// rel-bookmark found
if ($el->getAttribute('rel') == 'bookmark') {
$class = 'u-url';
// rel-bookmark already has class-attribute; append current value
if ($el->hasAttribute('class')) {
$class .= ' ' . $el->getAttribute('class');
}
$el->setAttribute('class', $class);
$class = 'u-url';
// rel-bookmark already has class attribute; append current value
if ($el->hasAttribute('class')) {
$class .= ' ' . $el->getAttribute('class');
}
$el->setAttribute('class', $class);
}
// Handle nested microformats (h-*)
......
......@@ -191,30 +191,30 @@ EOT;
<article class="hentry">
<span class="author">Lee Adama</span>
<span class="entry-title">Jumping Rope for Weight Loss</span>
<span class="entry-title"><a rel="bookmark" class="something" href="/2014/11/24/jump-rope">Jumping Rope for Weight Loss</a></span>
<div class="entry-content">Some Content</div>
<a rel="bookmark" href="/2014/11/24/jump-rope">Nov 24, 2014</a>
Nov 24, 2014
</article>
<article class="hentry">
<span class="author">Kara Thrace</span>
<span class="entry-title">Abstract Art in Graffiti</span>
<span class="entry-title"><a rel="bookmark" class="" href="/2014/11/23/graffiti">Abstract Art in Graffiti</a></span>
<div class="entry-content">More Content</div>
<a rel="bookmark" href="/2014/11/23/graffiti">Nov 23, 2014</a>
Nov 23, 2014
</article>
<article class="hentry">
<span class="author">President Roslyn</span>
<span class="entry-title">Dreams of Earth</span>
<span class="entry-title"><a rel="something bookmark" href="/2014/11/21/earth">Dreams of Earth</a></span>
<div class="entry-content">Additional Content</div>
<a rel="bookmark" href="/2014/11/21/earth">Nov 21, 2014</a>
Nov 21, 2014
</article>
<article class="hentry">
<span class="author">Chief Tyrrol</span>
<span class="entry-title">Organized Labor in Mining Colonies</span>
<span class="entry-title"><a rel="something bookmark somethingelse" class="somethingelse" href="/2014/11/19/labor">Organized Labor in Mining Colonies</a></span>
<div class="entry-content">More Content</div>
<a rel="bookmark" href="/2014/11/19/labor">Nov 19, 2014</a>
Nov 19, 2014
</article>
</body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment