Skip to content

Commit

Permalink
decode html entities
Browse files Browse the repository at this point in the history
  • Loading branch information
geminorum committed Jan 1, 2019
1 parent 801a792 commit 98b79d1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/virastar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Virastar.prototype.parseOptions = function (options) {
var defaults = {
normalize_eol: true,
decode_htmlentities: true,
fix_dashes: true,
fix_three_dots: true,
fix_english_quotes_pairs: true,
Expand Down Expand Up @@ -127,6 +128,13 @@
text = text.replace(/(\r?\n)|(\r\n?)/g, '\n');
}

// Converts an html characterSet into its original character
if (opts.decode_htmlentities) {
text = text.replace(/&#(\d+);/g, function (matched, dec) {
return String.fromCharCode(dec);
});
}

// replace double dash to ndash and triple dash to mdash
if (opts.fix_dashes) {
text = text.replace(/-{3}/g, '—');
Expand Down

0 comments on commit 98b79d1

Please sign in to comment.