Commit 3d5b9c94 authored by Alexandra Rogova's avatar Alexandra Rogova

better regex

parent 677c64a2
......@@ -58,24 +58,8 @@
})
.declareMethod("remove_css", function(body){
var regEx,
result;
regEx = new RegExp('<style.*/>');
do {
result = regEx.exec(body);
body_before = body.slice(0, result.index);
body_after = body.slice(result.index+result[0].length+1);
body = body_before+body_after;
} while (result !== null);
regEx = new RegExp('(<span style=.*>|&lt;span style.*&quot;&gt)');
do {
result = regEx.exec(body);
body_before = body.slice(0, result.index);
body_after = body.slice(result.index+result[0].length+1);
body = body_before+'<span>'+body_after;
} while (result !== null);
var regEx = new RegExp('(style="(.*?)"|style=&quot(.*?)&quot)', 'gi');
return body.replace(regEx, "");
})
.declareMethod("is_already_parsed", function(storage, title){
......
......@@ -40,10 +40,8 @@
parser = new DOMParser();
xmlDoc = parser.parseFromString(item.body,"text/xml");
body_text = xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;
console.log("ok : " + item.title);
return this.cut_description(body_text, key)
.push(function (result){
//console.log(item.title);
if (result === null) body.innerHTML = "";
else body.innerHTML = result.slice(1);
list_item.appendChild(body);
......@@ -63,8 +61,9 @@
.declareMethod("cut_description", function(body, key){
var regEx,
result;
regEx = new RegExp('[^.]*' +" " + key + " " + '[^.]*\.', 'g');
regEx = new RegExp('[^.?!]*' + ' ' + key + ' ' + '[^.?!]*[.?!]', 'gm');
result = regEx.exec(body);
console.log("result:");console.log(result);
if (result === null) return null;
else return result[0];
});
......
......@@ -60,7 +60,6 @@
promise_list = [],
i;
for (i = 0; i < gadget.state.to_load.length; i++){
//console.log(gadget.state.parser_gadget);
promise_list.push(gadget.state.parser_gadget.read_file("./test-files/" + gadget.state.to_load[i]));
}
RSVP.all(promise_list);
......@@ -71,7 +70,7 @@
options;
options = {
query:'(title:"% '+key+' %") OR (title:"'+ key + '%") OR (body:"% '+key+' %")'
query:'(title:"% '+key+' %") OR (title:"'+ key + ' %") OR (body:"% '+key+' %")'
};
return gadget.state.result_gadget.clear()
......
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