Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] scrape more lines, keep new lines

  • Loading branch information...
commit 52e689f817029ea18edede52c88d1f0bf9983fd5 1 parent 981176f
Martijn Swaagman Swaagie authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 index.js
7 index.js
View
@@ -6,11 +6,10 @@ var path = require('path'),
lunr = require('lunr'),
tokenizer = new natural.WordTokenizer(),
loc = path.resolve(__dirname, 'content'),
- html = /(<[^>]*>)|(&[^;]+;)/g,
scraper = {
title: /\[meta:title\]:\s<>\s\((.+?)\)(?!\))/,
description: /\[meta:description\]:\s<>\s\((.+?)\)(?!\))/,
- firstline: /([\-a-zA-Z0-9&;,]*\s+){5,}\w*/
+ firstlines: /^((.*\n){2}){1,3}/
};
//
@@ -23,7 +22,7 @@ var path = require('path'),
function scrape(content, key, n) {
if (!content) return '';
- var match = content.replace(/\n/g, ' ').match(scraper[key]);
+ var match = content.match(scraper[key]);
// Only return scraped content if there is a meta:[key].
return match && match[n] ? match[n].trim() : '';
@@ -48,7 +47,7 @@ function normalize(file) {
function fileContent(content) {
return {
content: content || '',
- description: scrape(content, 'description', 1) || scrape(content, 'firstline', 0),
+ description: scrape(content, 'description', 1) || scrape(content, 'firstlines', 0),
title: scrape(content, 'title', 1),
tags: tags(content, 10)
};
Please sign in to comment.
Something went wrong with that request. Please try again.