From 79b9cd4500807d27359d851bde137a276d32a8f8 Mon Sep 17 00:00:00 2001 From: gauthiier Date: Sun, 17 Aug 2014 14:08:01 +0200 Subject: [PATCH] esacped html --- generatebib.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/generatebib.js b/generatebib.js index dcfb98a..6d75f33 100644 --- a/generatebib.js +++ b/generatebib.js @@ -72,10 +72,10 @@ var conf = (fs.existsSync('config.json') ? JSON.parse(fs.readFileSync('config.js conf = _.extend({}, conf_default, conf); var locales = { - 'en-US': fs.readFileSync('csl-locales/locales-en-US.xml', 'utf8'), - 'English': fs.readFileSync('csl-locales/locales-en-US.xml', 'utf8'), - 'fr-FR': fs.readFileSync('csl-locales/locales-fr-FR.xml', 'utf8'), - 'French': fs.readFileSync('csl-locales/locales-fr-FR.xml', 'utf8') + 'en-US': fs.readFileSync(conf.csl_locales_path + 'locales-en-US.xml', 'utf8'), + 'English': fs.readFileSync(conf.csl_locales_path + 'locales-en-US.xml', 'utf8'), + 'fr-FR': fs.readFileSync(conf.csl_locales_path + 'locales-fr-FR.xml', 'utf8'), + 'French': fs.readFileSync(conf.csl_locales_path + 'locales-fr-FR.xml', 'utf8') }; var style_file = conf.csl_path + conf.style + '.csl'; @@ -186,6 +186,13 @@ for(var i = 0; i < fragments.length; i++) { html = "\n\t\n\n" + html + "\n"; output += html; } + } else if(conf.output == "txt") { + var txt = totxt(bib); + if(input) { + output = inject(output, frag.token, txt); + } else { + output += txt; + } } } @@ -202,8 +209,7 @@ function inject(data, token, input) { function tomarkdown(bib) { var md = ""; _.each(bib[1], function (e) { - md += (">" + e); - md += "\n>\n"; + md += (">" + escape_csl_entry(e).replace("", "*").replace("", "*") + "\n"); }); return md; } @@ -217,4 +223,20 @@ function tohtml(bib) { return html; } +function totxt(bib) { + var txt = ""; + _.each(bib[1], function (e) { + txt += escape_csl_entry(escape_italic(e)) + "\n"; + }); + return txt; +} + +function escape_csl_entry(b) { + return b.replace("
", "").replace("
", ""); +} + +function escape_italic(b) { + return b.replace("", "").replace("", ""); +} +