Commit 67cb4920 authored by Dan's avatar Dan

Merge branch 'develop' into 'master'

Develop

See merge request !108
parents 6f14d1fd 703fbf98
Pipeline #45 failed with stages
in 18 seconds
......@@ -165,4 +165,115 @@ local.properties
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
\ No newline at end of file
.worksheetdata/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.idea/
data/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.idea/
Necessite les programmes node et npm
Necessite spécifier le dossier de l'executable decac dans :
routes/index.js => variable bin_decac
Dépendances automatiques avec package.json (commande 'npm install')
Point d'entré :
bin/www
Par défaut, port d'écoute 8078
Changement possible dans bin/www ligne 15
Application réalisée via le logiciel Jetbrains WebStorm
\ No newline at end of file
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var index = require('./routes/index');
var about = require('./routes/about');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', index);
app.use('/about',about);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('decaonline:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort('8078');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
Saving the data directory in git
\ No newline at end of file
{
"name": "decaonline",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.17.1",
"cookie-parser": "~1.4.3",
"debug": "~2.6.3",
"ejs": "~2.5.6",
"express": "~4.15.2",
"morgan": "~1.8.1",
"serve-favicon": "~2.4.2"
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="188.068px" height="120.025px" viewBox="0 0 188.068 120.025" enable-background="new 0 0 188.068 120.025"
xml:space="preserve">
<g>
<g>
<g>
<path fill="#00A1E4" d="M148.928,53.372c1.184,12.826,0.754,25.758-1.281,38.437l7.078,1.136
c2.128-13.271,2.58-26.806,1.34-40.231L148.928,53.372z"/>
</g>
</g>
<g>
<g>
<path fill="#00A1E4" d="M140.4,14.956c1.955,5.439,3.627,11.063,4.967,16.716l6.975-1.653c-1.402-5.912-3.15-11.796-5.197-17.486
L140.4,14.956z"/>
</g>
</g>
<g>
<g>
<path fill="#91278F" d="M109.637,105.209c3.822-10.438,5.758-21.42,5.758-32.642c0-6.023-0.567-12.051-1.686-17.916l6.002-1.146
c1.19,6.242,1.795,12.654,1.795,19.062c0,11.939-2.063,23.628-6.131,34.741L109.637,105.209z"/>
</g>
</g>
<g>
<g>
<path fill="#C1272D" d="M119.92,117.507c6.404-14.155,9.651-29.274,9.651-44.939c0-3.725-0.188-7.48-0.562-11.162l6.079-0.617
c0.394,3.886,0.595,7.849,0.595,11.779c0,16.539-3.432,32.506-10.197,47.458L119.92,117.507z"/>
</g>
</g>
<g>
<g>
<path fill="#F7931E" d="M121.469,31.22c-4.039-9.856-9.504-19.064-16.243-27.369L109.971,0
c7.115,8.769,12.887,18.494,17.151,28.902L121.469,31.22z"/>
</g>
</g>
<g>
<g>
<path fill="#8CC63F" d="M167.744,80.247c0.203-2.549,0.344-5.137,0.419-7.696c0.401-13.66-1.017-27.253-4.216-40.403l5.938-1.443
c3.327,13.68,4.803,27.819,4.387,42.025c-0.079,2.661-0.226,5.353-0.435,8.001L167.744,80.247z"/>
</g>
</g>
<path fill="#0054A6" d="M188.026,68.735l-6.109,0.137c0.026,1.214,0.041,2.457,0.041,3.695c0,5.597-0.284,11.241-0.845,16.777
c-0.499,4.919-1.228,9.869-2.168,14.709l3,0.582v0.001v-0.001l3,0.582c0.973-5.021,1.73-10.154,2.246-15.257
c0.583-5.741,0.877-11.592,0.877-17.394C188.068,71.284,188.055,69.995,188.026,68.735z"/>
<g>
<path fill="#808285" d="M10.034,48.819c-1.176,1.241-2.635,1.764-4.268,1.764c-1.612,0-3.005-0.588-4.072-1.654
c-1.524-1.524-1.502-3.244-1.502-6.228s-0.022-4.703,1.502-6.228c1.067-1.066,2.418-1.654,4.072-1.654
c3.288,0,5.204,2.155,5.639,4.812H9.032c-0.392-1.698-1.524-2.7-3.266-2.7c-0.915,0-1.742,0.371-2.286,0.959
c-0.763,0.827-0.937,1.697-0.937,4.812c0,3.113,0.174,4.006,0.937,4.834c0.544,0.588,1.371,0.936,2.286,0.936
c1.023,0,1.917-0.392,2.526-1.089c0.566-0.652,0.784-1.437,0.784-2.438v-0.871h-3.31v-2.004h5.662v2.374
C11.428,46.446,11.057,47.731,10.034,48.819z"/>
</g>
<g>
<path fill="#808285" d="M22.88,42.005c-0.5-0.501-0.893-0.74-1.655-0.74c-1.197,0-2.199,0.957-2.199,2.482v6.705h-2.221V39.413
h2.178v1.197c0.566-0.783,1.698-1.328,2.939-1.328c1.067,0,1.873,0.283,2.635,1.046L22.88,42.005z"/>
</g>
<g>
<path fill="#808285" d="M29.472,45.575c0,1.895,1.001,3.091,2.81,3.091c1.241,0,1.894-0.348,2.678-1.131l1.416,1.328
c-1.132,1.132-2.2,1.72-4.137,1.72c-2.766,0-4.965-1.459-4.965-5.661c0-3.571,1.852-5.64,4.682-5.64
c2.961,0,4.681,2.178,4.681,5.313v0.979H29.472z M34.132,42.526C33.784,41.7,33,41.133,31.955,41.133s-1.851,0.567-2.2,1.394
c-0.217,0.501-0.261,0.828-0.283,1.503h4.965C34.415,43.354,34.35,43.027,34.132,42.526z"/>
</g>
<g>
<path fill="#808285" d="M48.48,50.452v-6.728c0-1.72-0.979-2.46-2.221-2.46s-2.287,0.762-2.287,2.46v6.728h-2.221V39.413h2.178
v1.11c0.762-0.827,1.829-1.241,2.939-1.241c1.132,0,2.068,0.371,2.722,1.002c0.849,0.827,1.111,1.872,1.111,3.113v7.055H48.48z"/>
</g>
<g>
<path fill="#808285" d="M63.679,49.276c-0.719,0.74-1.808,1.307-3.31,1.307c-1.502,0-2.569-0.566-3.288-1.307
c-1.045-1.089-1.306-2.481-1.306-4.354c0-1.851,0.261-3.244,1.306-4.333c0.719-0.74,1.786-1.307,3.288-1.307
c1.502,0,2.591,0.566,3.31,1.307c1.045,1.089,1.306,2.482,1.306,4.333C64.985,46.795,64.725,48.188,63.679,49.276z M62.002,41.896
c-0.414-0.413-0.979-0.631-1.633-0.631s-1.197,0.218-1.611,0.631c-0.675,0.675-0.763,1.829-0.763,3.026s0.087,2.352,0.763,3.027
c0.414,0.413,0.958,0.652,1.611,0.652s1.219-0.239,1.633-0.652c0.675-0.676,0.763-1.83,0.763-3.027S62.677,42.57,62.002,41.896z"
/>
</g>
<g>
<path fill="#808285" d="M77.962,49.604c-0.609,0.609-1.589,0.979-2.7,0.979c-1.196,0-2.09-0.305-2.917-1.307v1.176h-2.177V34.949
h2.221v5.574c0.806-0.958,1.72-1.241,2.896-1.241c1.11,0,2.068,0.371,2.677,0.98c1.11,1.11,1.241,2.983,1.241,4.659
C79.203,46.599,79.072,48.492,77.962,49.604z M74.697,41.265c-2.003,0-2.308,1.698-2.308,3.657c0,1.96,0.305,3.68,2.308,3.68
s2.286-1.72,2.286-3.68C76.983,42.963,76.7,41.265,74.697,41.265z"/>
</g>
<g>
<path fill="#808285" d="M87.347,50.452c-2.113,0-3.027-1.415-3.027-3.048V34.949h2.22v12.324c0,0.85,0.305,1.285,1.199,1.285
h0.979v1.894H87.347z"/>
</g>
<g>
<path fill="#808285" d="M94.419,45.575c0,1.895,1.001,3.091,2.809,3.091c1.242,0,1.895-0.348,2.678-1.131l1.415,1.328
c-1.132,1.132-2.198,1.72-4.136,1.72c-2.766,0-4.965-1.459-4.965-5.661c0-3.571,1.852-5.64,4.682-5.64
c2.961,0,4.681,2.178,4.681,5.313v0.979H94.419z M99.078,42.526c-0.348-0.826-1.131-1.394-2.176-1.394
c-1.046,0-1.852,0.567-2.199,1.394c-0.219,0.501-0.262,0.828-0.284,1.503h4.965C99.362,43.354,99.297,43.027,99.078,42.526z"/>
</g>
<g>
<path fill="#8CC63F" d="M113.907,50.452V34.949h3.812v15.503H113.907z"/>
</g>
<g>
<path fill="#8CC63F" d="M131.805,50.452l-4.965-7.794v7.794h-3.811V34.949h3.331l4.966,7.796v-7.796h3.811v15.503H131.805z"/>
</g>
<g>
<path fill="#8CC63F" d="M146.589,44.922h-2.329v5.53h-3.811V34.949h6.14c3.44,0,5.292,2.439,5.292,4.986
C151.881,42.483,150.029,44.922,146.589,44.922z M146.415,38.368h-2.155v3.136h2.155c1.046,0,1.655-0.763,1.655-1.568
C148.07,39.131,147.461,38.368,146.415,38.368z"/>
</g>
<g>
<g>
<path fill="#8CC63F" d="M12.803,74.862c0,1.146-0.581,1.72-1.743,1.72H5.229C1.741,76.582,0,74.8,0,71.237V63.22
c0-1.161,0.581-1.742,1.741-1.742h9.227c1.216-0.009,1.824,0.569,1.824,1.731c-0.007,1.131-0.601,1.708-1.777,1.73l-7.529-0.012
v2.324l5.216-0.023c1.178,0.016,1.766,0.616,1.766,1.801c0.007,1.131-0.569,1.696-1.73,1.696l-5.252,0.012v0.581
c0,1.186,0.592,1.777,1.777,1.777l5.833,0.011C12.234,73.106,12.803,73.692,12.803,74.862z"/>
</g>
<g>
<path fill="#8CC63F" d="M15.126,74.792V63.209c0-1.146,0.581-1.721,1.744-1.721l5.832-0.011c3.486,0,5.229,1.781,5.229,5.345
v8.017c0,1.162-0.581,1.743-1.742,1.743c-1.162,0-1.743-0.589-1.743-1.767v-8.063c0-1.193-0.589-1.789-1.766-1.789h-4.067v9.828
c0,1.179-0.589,1.767-1.767,1.767C15.698,76.559,15.126,75.971,15.126,74.792z"/>
</g>
<g>
<path fill="#8CC63F" d="M40.175,64.964h-4.66c-1.185,0-1.778,0.395-1.778,1.184c0,0.744,0.597,1.116,1.79,1.116h1.127
c3.469,0.054,5.201,1.603,5.192,4.646c-0.015,3.092-1.746,4.641-5.192,4.648l-4.706-0.011c-1.123,0.006-1.688-0.528-1.696-1.604
c0.008-1.208,0.569-1.815,1.685-1.824h4.694c1.154,0,1.738-0.395,1.754-1.186c0-0.766-0.573-1.157-1.72-1.173h-1.127
c-3.509,0.016-5.259-1.546-5.251-4.683c-0.023-3.067,1.708-4.601,5.194-4.601l4.647,0.011c1.162,0,1.743,0.574,1.743,1.721
C41.847,64.355,41.282,64.939,40.175,64.964z"/>
</g>
<g>
<path fill="#8CC63F" d="M47.738,76.559c-1.179,0-1.767-0.588-1.767-1.767v-9.828c-1.177,0-1.759-0.563-1.742-1.686
c0-1.177,0.58-1.778,1.742-1.801l1.743-0.022c1.162,0.022,1.743,0.607,1.743,1.754v11.583
C49.457,75.971,48.883,76.559,47.738,76.559z M46.767,57.039c-0.274,0.147-0.489,0.36-0.646,0.64
c-0.154,0.278-0.232,0.568-0.232,0.87c0,0.295,0.078,0.579,0.232,0.854c0.156,0.274,0.369,0.487,0.64,0.639
c0.271,0.151,0.558,0.227,0.86,0.227c0.293,0,0.579-0.075,0.854-0.227c0.274-0.151,0.487-0.364,0.638-0.639
c0.151-0.275,0.226-0.56,0.226-0.854c0-0.302-0.077-0.592-0.232-0.87c-0.155-0.279-0.37-0.492-0.645-0.64
s-0.556-0.221-0.842-0.221C47.326,56.818,47.041,56.892,46.767,57.039z"/>
</g>
<g>
<path fill="#8CC63F" d="M66.314,61.478c3.487,0,5.229,1.781,5.229,5.345v8.017c0,1.162-0.581,1.743-1.742,1.743
c-1.163,0-1.743-0.589-1.743-1.767v-8.063c0-1.193-0.593-1.789-1.777-1.789h-2.895l0.024,9.875c0,1.162-0.581,1.743-1.743,1.743
s-1.742-0.589-1.742-1.767v-8.063c0-1.193-0.589-1.789-1.767-1.789h-2.881v9.828c0,1.179-0.588,1.767-1.766,1.767
c-1.146,0-1.72-0.588-1.72-1.767V63.209c0-1.146,0.593-1.731,1.778-1.754L66.314,61.478z"/>
</g>
<g>
<path fill="#8CC63F" d="M84.915,76.582c-1.185,0-1.778-0.589-1.778-1.767v-2.893l-5.774-0.013l-0.013,2.905
c0,1.178-0.58,1.767-1.742,1.767c-1.162,0-1.743-0.581-1.743-1.743v-8.017c0-3.563,1.743-5.345,5.228-5.345l5.787,0.011
c1.162,0,1.743,0.574,1.743,1.721v11.606C86.623,75.993,86.053,76.582,84.915,76.582z M83.137,68.413v-3.449h-4.009
c-1.185,0-1.778,0.596-1.778,1.789v1.66H83.137z"/>
</g>
<g>
<path fill="#8CC63F" d="M101.796,63.209v12.873c0,3.432-1.743,5.147-5.229,5.147h-3.624c-1.116,0-1.678-0.581-1.686-1.743
c-0.007-1.154,0.546-1.73,1.662-1.73h4.148c0.829,0.007,1.244-0.396,1.244-1.208h-4.09c-3.486,0-5.229-1.782-5.229-5.346v-4.474
c0-3.523,1.763-5.286,5.288-5.286h5.809C101.227,61.442,101.796,62.031,101.796,63.209z M94.244,64.939
c-1.178,0-1.766,0.597-1.766,1.789v4.543c0,1.193,0.592,1.79,1.778,1.79h4.055v-8.122H94.244z"/>
</g>
</g>
</g>
</svg>
This diff is collapsed.
/*
Copyright (C) 2006 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
HTML decoding functionality provided by: http://code.google.com/p/google-trekker/
*/
function htmlToText(html, extensions) {
var text = html;
if (extensions && extensions['preprocessing'])
text = extensions['preprocessing'](text);
text = text
// Remove line breaks
.replace(/(?:\n|\r\n|\r)/ig, " ")
// Remove content in script tags.
.replace(/<\s*script[^>]*>[\s\S]*?<\/script>/mig, "")
// Remove content in style tags.
.replace(/<\s*style[^>]*>[\s\S]*?<\/style>/mig, "")
// Remove content in comments.
.replace(/<!--.*?-->/mig, "")
// Remove !DOCTYPE
.replace(/<!DOCTYPE.*?>/ig, "");
/* I scanned http://en.wikipedia.org/wiki/HTML_element for all html tags.
I put those tags that should affect plain text formatting in two categories:
those that should be replaced with two newlines and those that should be
replaced with one newline.
I process <DEL> and <INS> as inline elements.
http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#h-9.4
"These two elements are unusual for HTML in that they may serve as either
block-level or inline elements (but not both). They may contain one or more
words within a paragraph or contain one or more block-level elements such
as paragraphs, lists and tables." */
if (extensions && extensions['tagreplacement'])
text = extensions['tagreplacement'](text);
var doubleNewlineTags = ['p', 'h[1-6]', 'dl', 'dt', 'dd', 'ol', 'ul',
'dir', 'address', 'blockquote', 'center', 'hr', 'pre', 'form',
'textarea', 'table'];
var singleNewlineTags = ['li', 'fieldset','div', 'legend', 'tr', 'th', 'caption',
'thead', 'tbody', 'tfoot'];
for (i = 0; i < doubleNewlineTags.length; i++) {
var r = RegExp('</?\\s*' + doubleNewlineTags[i] + '[^>]*>', 'ig');
text = text.replace(r, '\n\n');
}
for (i = 0; i < singleNewlineTags.length; i++) {
var r = RegExp('<\\s*' + singleNewlineTags[i] + '[^>]*>', 'ig');
text = text.replace(r, '\n');
}
// Replace <br> and <br/> with a single newline
//text = text.replace(/<\s*br[^>]*\/?\s*>/ig, '\n');
text = text
// Remove all remaining tags.
.replace(/(<([^>]+)>)/ig,"")
// Trim rightmost whitespaces for all lines
.replace(/([^\n\S]+)\n/g,"\n")
.replace(/([^\n\S]+)$/,"")
// Make sure there are never more than two
// consecutive linebreaks.
.replace(/\n{2,}/g,"\n\n")
// Remove newlines at the beginning of the text.
.replace(/^\n+/,"")
// Remove newlines at the end of the text.
.replace(/\n+$/,"")
// Decode HTML entities.
.replace(/&([^;]+);/g, decodeHtmlEntity);
if (extensions && extensions['postprocessing'])
text = extensions['postprocessing'](text);
return text;
}
function decodeHtmlEntity(m, n) {
// Determine the character code of the entity. Range is 0 to 65535
// (characters in JavaScript are Unicode, and entities can represent
// Unicode characters).
var code;
// Try to parse as numeric entity. This is done before named entities for
// speed because associative array lookup in many JavaScript implementations
// is a linear search.
if (n.substr(0, 1) == '#') {
// Try to parse as numeric entity
if (n.substr(1, 1) == 'x') {
// Try to parse as hexadecimal
code = parseInt(n.substr(2), 16);
} else {
// Try to parse as decimal
code = parseInt(n.substr(1), 10);
}
} else {
// Try to parse as named entity
code = ENTITIES_MAP[n];
}
// If still nothing, pass entity through
return (code === undefined || code === NaN) ?
'&' + n + ';' : String.fromCharCode(code);
}
var ENTITIES_MAP = {
'nbsp' : 160,
'iexcl' : 161,
'cent' : 162,
'pound' : 163,
'curren' : 164,
'yen' : 165,
'brvbar' : 166,
'sect' : 167,
'uml' : 168,
'copy' : 169,
'ordf' : 170,
'laquo' : 171,
'not' : 172,
'shy' : 173,
'reg' : 174,
'macr' : 175,
'deg' : 176,
'plusmn' : 177,
'sup2' : 178,
'sup3' : 179,
'acute' : 180,
'micro' : 181,
'para' : 182,
'middot' : 183,
'cedil' : 184,
'sup1' : 185,
'ordm' : 186,
'raquo' : 187,
'frac14' : 188,
'frac12' : 189,
'frac34' : 190,
'iquest' : 191,
'Agrave' : 192,
'Aacute' : 193,
'Acirc' : 194,
'Atilde' : 195,
'Auml' : 196,
'Aring' : 197,
'AElig' : 198,
'Ccedil' : 199,
'Egrave' : 200,
'Eacute' : 201,