Added more weight to section tags.

pull/142/head
Nicolas Perriault 9 years ago
parent 647658a47b
commit d188d89e02

@ -101,6 +101,9 @@ Readability.prototype = {
// it quits and just show a link.
DEFAULT_MAX_PAGES: 5,
// Element tags to score by default.
DEFAULT_TAGS_TO_SCORE: ["SECTION", "P", "TD", "PRE"],
// All of the regular expressions in use within readability.
// Defined up here so we don't instantiate them repeatedly in loops.
REGEXPS: {
@ -436,6 +439,8 @@ Readability.prototype = {
node.readability = {"contentScore": 0};
switch(node.tagName) {
case 'MAIN':
case 'ARTICLE':
case 'DIV':
node.readability.contentScore += 5;
break;
@ -468,6 +473,13 @@ Readability.prototype = {
break;
}
switch(node.getAttribute("role")) {
case 'article':
case 'main':
node.readability.contentScore += 5;
break;
}
node.readability.contentScore += this._getClassWeight(node);
},
@ -604,7 +616,7 @@ Readability.prototype = {
}
}
if (node.tagName === "P" || node.tagName === "TD" || node.tagName === "PRE")
if (this.DEFAULT_TAGS_TO_SCORE.indexOf(node.tagName) !== -1)
elementsToScore.push(node);
// Turn all divs that don't have children block level elements into p's
@ -624,11 +636,17 @@ Readability.prototype = {
// EXPERIMENTAL
this._forEachNode(node.childNodes, function(childNode) {
if (childNode.nodeType === Node.TEXT_NODE) {
var textContent = childNode.textContent.trim();
if (textContent) {
var p = doc.createElement('p');
p.textContent = childNode.textContent;
p.style.display = 'inline';
p.className = 'readability-styled';
node.replaceChild(p, childNode);
} else {
// remove empty text nodes
node.removeChild(childNode);
}
}
});
}

@ -2,7 +2,6 @@
<div>
<div class="article-media article-media-main">
<div class="image">
<div class="image-frame"><img data-src="http://api.news.com.au/content/1.0/heraldsun/images/1227261885862?format=jpg&amp;group=iphone&amp;size=medium" alt="A new Bill would require telecommunications service providers to store so-called metadat"></div>
<p class="caption"> <span id="imgCaption" class="caption-text">A new Bill would require telecommunications service providers to store so-called metadata for two years.</span> <span class="image-source"><em>Source:</em>
Supplied</span> </p>
</div>

@ -1,5 +1,13 @@
<div id="readability-page-1" class="page">
<div>
<article lang="en" data-allow-notes="true">
<section class="postWrapper postWrapper--contain">
<div class="postWrapper-inner">
<div class="postContent">
<div class="postContent-inner">
<div class="notesSource">
<div class="postField postField--body">
<section name="ef8c" class=" section--first section--last">
<div class="section-content">
<div class="section-inner u-sizeFullWidth">
<figure name="b9ad" id="b9ad" class="graf--figure postField--fillWidthImage graf--first">
<div class="aspectRatioPlaceholder is-locked"><img class="graf-image" data-image-id="1*sLDnS1UWEFIS33uLMxq3cw.jpeg" data-width="2100" data-height="1402" src="https://d262ilb51hltx0.cloudfront.net/max/2000/1*sLDnS1UWEFIS33uLMxq3cw.jpeg"></div>
@ -153,4 +161,55 @@
<p name="c30a" id="c30a" data-align="center" class="graf--p graf--last">Follow Backchannel: <a href="https://twitter.com/backchnnl" data-href="https://twitter.com/backchnnl" class="markup--anchor markup--p-anchor" rel="nofollow"><em class="markup--em markup--p-em">Twitter</em></a> <em class="markup--em markup--p-em">|</em><a href="https://www.facebook.com/pages/Backchannel/1488568504730671" data-href="https://www.facebook.com/pages/Backchannel/1488568504730671" class="markup--anchor markup--p-anchor" rel="nofollow"><em class="markup--em markup--p-em">Facebook</em></a> </p>
</div>
</div>
</section>
</div>
</div>
<div class="postFooter--simple2 supplementalPostContent layoutSingleColumn js-postFooter">
<div class="u-clearfix postFooter-actions--simple2">
<div class="u-floatRight">
<p class="buttonSet">
<button class="button button--vertical button--bookmark js-bookmarkButton" title="Bookmark this story to read later" data-action="sign-in-prompt" data-requires-token="true" data-redirect="/_/bookmark/p/9718cd0fe504"><span class="icon icon--readingList2outline icon--default"></span> <span class="icon icon--active icon--readingList2"></span><span class="label label--default">Bookmark</span><span class="label label--active">Bookmarked</span> </button>
<button class="button button--vertical button--share" title="Share this story on Twitter, Facebook, or email" data-action="show-share-popover" data-action-value="9718cd0fe504" data-action-source="footer"><span class="icon icon--share2Outline "></span><span class="label ">Share</span> </button>
<button class="button button--vertical u-xs-hide button--more" title="More actions" data-action="more-actions"><span class="icon icon--arrowDownThin "></span><span class="label ">More</span> </button>
</p>
</div>
</div>
<div class="postFooter-info js-postFooterInfo">
<div class="infoCard u-clearfix js-infoCardCollection">
<div class="infoCard-info ">
<div class="infoCard-wrapper">
<p class="infoCard-title">Published in</p><a class="link link--primary js-logCollection" title="Go to Backchannel" href="https://medium.com/backchannel" data-action-source="footer">Backchannel</a>
<p class="infoCard-bio">Mining the tech world for lively and meaningful tales and analysis.</p>
</div>
</div>
<div class="infoCard-actions">
<button class="button button--small infoCard-showSubscribeForm" data-action="toggle-css-class" data-action-value="is-emailFollowActive" data-action-target="js-infoCardCollection"><span class="button-label ">Follow by email</span> </button>
<div class="infoCard-emailFollow">
<p class="infoCard-emailFollowTitle u-xs-hide">Email me when there are new stories in the publication</p>
<button class="button button--primary button--small u-verticalAlignTop" data-action="subscribe-by-email" data-action-target="js-emailToSubscribeCollection">Follow</button>
</div>
</div>
</div>
<hr class="infoCard-border">
<div class="infoCard u-clearfix js-infoCardUser">
<div class="infoCard-info ">
<div class="infoCard-wrapper">
<p class="infoCard-title">Written <span class="postMetaInline postMetaInline--date"><span class="u-xs-hide"> on </span>
<time class="post-date">Mar 27</time>
</span>by</p><a class="link link--primary" title="Go to the profile of Joseph Cox" href="https://medium.com/@josephfcox">Joseph Cox</a>
<div class="infoCard-bio">
<p style="display: inline;" class="readability-styled">Encryption Enthusiast. Words for Motherboard, WIRED, Daily Dot. Documentaries for VICE. OTR chat: </p><a rel="nofollow" href="mailto:jfcox@jabber.ccc.de">jfcox@jabber.ccc.de</a></div>
</div>
</div>
<p class="infoCard-actions"><span class="followState js-followState"><button class="button button--small button--toggle u-noUserSelect button--follow" title="Follow to get new stories and recommendations from this author" data-action="sign-in-prompt" data-requires-token="true" data-redirect="https://medium.com/_/subscribe/user/99f6d9c3c62c/9718cd0fe504"><span class="button-label label--default">Follow</span> <span class="button-label label--active">Following</span> </button>
</span>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</article>
</div>

@ -0,0 +1,7 @@
{
"title": "Firefox — Customize and make it your own — The most flexible browser on the Web",
"byline": null,
"dir": "ltr",
"excerpt": "Its easier than ever to personalize Firefox and make it work the way\n you do.\n No other browser gives you so much choice and flexibility.",
"readerable": true
}

@ -0,0 +1,54 @@
<div id="readability-page-1" class="page">
<div role="main" id="main-content">
<section id="intro">
<div class="container">
<p class="lead">Its easier than ever to personalize Firefox and make it work the way you do.
<br class="wide-br">No other browser gives you so much choice and flexibility.</p>
</div>
</section>
<section id="designed" class="ga-section" data-ga-label="Designed to be redesigned">
<div class="container">
<div id="designed-copy">
<h2>Designed to <br class="wide-br">be redesigned</h2>
<p>Get fast and easy access to the features you use most in the new menu. Open the “Customize” panel to add, move or remove any button you want. Keep your favorite features — add-ons, private browsing, Sync and more — one quick click away.</p><img class="js " src="" data-processed="false" data-src="//mozorg.cdn.mozilla.net/media/img/firefox/desktop/customize/designed-redesigned.fbd3ee9402e6.png" data-high-res="true" data-high-res-src="//mozorg.cdn.mozilla.net/media/img/firefox/desktop/customize/designed-redesigned-high-res.6efd60766484.png" alt="" id="designed-mobile"></div>
</div>
</section>
<section id="customize" class="ga-section" data-ga-label="More ways to customize"> </section>
<div id="customizers-wrapper">
<section class="customizer active" id="themes" role="tabpanel" aria-labelledby="customize-themes">
<div class="container">
<div class="customizer-copy">
<h3>Themes</h3>
<p class="lead">Make Firefox match your style. Choose from thousands of themes and dress up your browser with a single click.</p>
<p id="themes-thumbs">
<button type="button" aria-controls="theme-demo" id="theme-yellow">Preview yellow theme</button>
<button type="button" aria-controls="theme-demo" id="theme-green">Preview green theme</button>
<button type="button" aria-controls="theme-demo" id="theme-blue">Preview blue theme</button>
<button type="button" aria-controls="theme-demo" id="theme-red" class="selected">Preview red theme</button>
</p><a class="more" rel="external" href="https://addons.mozilla.org/firefox/themes/">Try it now</a>
<br><a class="more" rel="external" href="https://support.mozilla.org/kb/use-themes-change-look-of-firefox">Learn more</a></div><a class="next show-customizer" href="http://fakehost/test/#add-ons" role="button">Next</a></div>
</section>
<section class="customizer" id="add-ons" role="tabpanel" aria-labelledby="customize-addons">
<div class="container">
<div class="customizer-copy">
<h3>Add-ons</h3><a class="next show-customizer" href="http://fakehost/test/#awesome-bar" role="button">Next</a>
<p class="lead">Add-ons are like apps that you install to add features to Firefox. They let you compare prices, check the weather, listen to music, send a tweet and more.</p>
<ul>
<li>Read the latest news &amp; blogs</li>
<li>Manage your downloads</li>
<li>Watch videos &amp; view photos</li>
</ul><a class="more" rel="external" href="https://addons.mozilla.org/firefox/extensions/?sort=featured">Here are a few of our favorites</a>
<br><a class="more" rel="external" href="https://support.mozilla.org/kb/find-and-install-add-ons-add-features-to-firefox">Learn more</a></div>
</div>
</section>
<section class="customizer" id="awesome-bar" role="tabpanel" aria-labelledby="customize-awesomebar">
<div class="container">
<div class="customizer-copy">
<h3>Awesome Bar</h3><a class="next show-customizer" href="http://fakehost/test/#themes" role="button">Next</a>
<p class="lead">The Awesome Bar learns as you browse to make your version of Firefox unique. Find and return to your favorite sites without having to remember a URL.</p><a class="more" rel="external" href="https://support.mozilla.org/kb/awesome-bar-find-your-bookmarks-history-and-tabs">See what it can do for you</a></div>
</div>
</section>
</div>
<section id="sync" class="ga-section" data-ga-label="Keep your Firefox in Sync"> </section>
</div>
</div>

File diff suppressed because it is too large Load Diff

@ -31,9 +31,6 @@
<p>The leader of Ennahda, Rachid Ghannouchi, condemned Wednesdays attack, saying in a statement that it “will not break our peoples will and will not undermine our revolution and our democracy.”</p>
<p>Security officials are particularly concerned by the collapse of Libya, where various armed groups are vying for influence and jihadist militants have entrenched themselves in major cities. Tunisians worry that extremists can easily get arms and training in the neighboring country.</p>
<p>In January, Libyan militants loyal to the Islamic State <a href="http://www.washingtonpost.com/world/middle_east/video-shows-purported-beheading-of-egyptian-christians-in-libya/2015/02/15/b8d0f092-b548-11e4-bc30-a4e75503948a_story.html">beheaded 21 Christians</a> — 20 of them Egyptian Copts — along the countrys coast. They later seized the Libyan city of Sirte.</p>
<div class="inline-content inline-graphic-embedded"><img class="unprocessed" data-hi-res-src="https://img.washingtonpost.com/rf/image_1484w/2010-2019/WashingtonPost/2015/03/18/Foreign/Graphics/tunisia600.jpg?uuid=1_yuLs2LEeSHME9HNBbnWQ" data-low-res-src="https://img.washingtonpost.com/rf/image_480w/2010-2019/WashingtonPost/2015/03/18/Foreign/Graphics/tunisia600.jpg?uuid=1_yuLs2LEeSHME9HNBbnWQ" src="https://img.washingtonpost.com/rf/image_480w/2010-2019/WashingtonPost/2015/03/18/Foreign/Graphics/tunisia600.jpg?uuid=1_yuLs2LEeSHME9HNBbnWQ">
<br>
</div>
<p>Officials are worried about the number of Tunisian militants who may have joined the jihadists in Libya — with the goal of returning home to fight the Tunis government.</p>
<p>Ajmi Lourimi, a member of Ennahdas general secretariat, said he believed the attack would unite Tunisians in the face of terrorism.</p>
<p>“There is a consensus here that this [attack] is alien to our culture, to our way of life. We want to unify against this danger,” Lourimi said. He said he did not expect a wider government campaign against Islamists.</p>

Loading…
Cancel
Save