Commit 677c64a2 authored by Alexandra Rogova's avatar Alexandra Rogova

test : remove styling in HTML while parsing

parent a86a462d
......@@ -47,7 +47,7 @@
link_end = local_cur_text.indexOf("</link>"),
body_start = local_cur_text.indexOf("<description>"),
body_end = local_cur_text.indexOf("</description>") + 14;
return this.parse_body(local_cur_text.slice(body_start, body_end))
return this.remove_css(local_cur_text.slice(body_start, body_end))
.push (function(result){
return storage.put({
"title": local_cur_text.slice(title_start, title_end),
......@@ -57,16 +57,25 @@
});
})
.declareMethod("parse_body", function(body){
/*var before,
after;
while (body.indexOf("&lt;span style") > -1){
before = body.slice(0, body.indexOf("&lt;span style"));
after = body.slice(body.indexOf("&quot;&gt"), body.length -1);
body = before + after;
}
console.log(body);*/
return body;
.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);
})
.declareMethod("is_already_parsed", function(storage, title){
......
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