mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-10 21:05:09 +00:00
added a page for jessica
This commit is contained in:
parent
d0d5164749
commit
d9e8f91fac
49
lib/clean.js
Normal file
49
lib/clean.js
Normal file
@ -0,0 +1,49 @@
|
||||
var http = require('http'), sys = require('sys');
|
||||
|
||||
module.exports = {
|
||||
|
||||
cleanit: function (req, res) {
|
||||
var r = {
|
||||
// from http://tim.mackey.ie/CleanWordHTMLUsingRegularExpressions.aspx
|
||||
msoTags: /<[\/]?(font|span|xml|del|ins|[ovwxp]:\w+)[^>]*?>/g,
|
||||
msoAttributes: /<([^>]*)(?:class|lang|style|size|face|[ovwxp]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>/,
|
||||
msoParagraphs: /<([^>]*)(?:|[p]:\w+)=(?:'[^']*'|""[^""]*""|[^\s>]+)([^>]*)>/g,
|
||||
crlf: /(\\r\\n)/g
|
||||
};
|
||||
|
||||
var front = '<?xml version="1.0" encoding="utf-8"?>\r\n <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r\n <html xmlns="http://www.w3.org/1999/xhtml">\r\n <head>\r\n <title>Spellbinder - Chapter </title>\r\n <link rel="stylesheet" type="text/css" href="imperaWeb.css"/>\r\n <link rel="stylesheet" type= "application/vnd.adobe-page-template+xml" href= "page-template.xpgt"/>\r\n </head>\r\n <body>\r\n <div id="text">\r\n <div class="section" id="xhtmldocuments">\r\n';
|
||||
var back = ' </div> </div> </body> </html> ';
|
||||
var source = req.body.source;
|
||||
// console.log(source);
|
||||
|
||||
var output = source.replace(r.msoTags, "");
|
||||
output = output.replace(r.msoParagraphs, '<p>');
|
||||
output = output.replace(/(\r\n)/g, " ");
|
||||
output = output.replace(/(\\r\\n)/g, " ");
|
||||
|
||||
output = output.replace(/<i><\/i>/g, "");
|
||||
output = output.replace(/[“|”]/g, '"');
|
||||
output = output.replace(/’/g, "'");
|
||||
output = output.replace(/…/g, "…");
|
||||
output = output.replace(/<i>(.*?)<\/i>/g, "<em>$1</em>");
|
||||
output = output.replace(/<b>(.*?)<\/b>/g, "<strong>$1</strong>");
|
||||
output = output.replace(/<p>\*\*\*<\/p>/g, "<p class='break'>* * *</p>");
|
||||
|
||||
output = output.replace(/<p>CHAPTER\s(\d.?)<\/p>/, "<h1>$1</h1>");
|
||||
output = output.replace(/<p>( |\s|<em>\s<\/em>)<\/p>/g, "");
|
||||
output = output.replace(/ /g, " ");
|
||||
|
||||
output = output.replace(/<p><em>\s<\/em><\/p>/g, "");
|
||||
output = output.replace(/<p>\s<\/p>/g, "");
|
||||
|
||||
output = output.replace(/\s+/g, " ");
|
||||
output = output.replace(/<\/p>/g, "</p>\r\n");
|
||||
|
||||
|
||||
|
||||
// sys.puts(sys.inspect(output, false, null));
|
||||
|
||||
res.setHeader('Content-Type', 'application/html');
|
||||
res.end(front + output + back);
|
||||
}
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
var express = require('express'), path = require('path'), http = require('http'),
|
||||
fx = require('./lib/fx'), btc = require('./lib/btc'), train = require('./lib/train'),
|
||||
password = require('./lib/password'), clean = require('./lib/clean')
|
||||
password = require('./lib/password') , clean = require('./lib/clean')
|
||||
//train = require('lib/train')
|
||||
/* ,submit = require('./routes/mongo/submit') */
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user