gettext-parser
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -51,2 +51,6 @@ const { Buffer } = require('safe-buffer'); | ||
if (!('escapeCharacters' in this._options)) { | ||
this._options.escapeCharacters = true; | ||
} | ||
if (!('sort' in this._options)) { | ||
@@ -158,13 +162,17 @@ this._options.sort = false; | ||
let { foldLength, eol, escapeCharacters } = this._options; | ||
// escape newlines and quotes | ||
value = value.toString() | ||
.replace(/\\/g, '\\\\') | ||
.replace(/"/g, '\\"') | ||
.replace(/\t/g, '\\t') | ||
.replace(/\r/g, '\\r') | ||
.replace(/\n/g, '\\n'); | ||
if (escapeCharacters) { | ||
value = value.toString() | ||
.replace(/\\/g, '\\\\') | ||
.replace(/"/g, '\\"') | ||
.replace(/\t/g, '\\t') | ||
.replace(/\r/g, '\\r'); | ||
} | ||
value = value.replace(/\n/g, '\\n'); // need to escape new line characters regardless | ||
let lines = [value]; | ||
let { foldLength, eol } = this._options; | ||
if (obsolete) { | ||
@@ -178,3 +186,5 @@ eol = eol + '#~ '; | ||
// split only on new lines | ||
lines = value.split(/(?<=\\n)/); | ||
if (escapeCharacters) { | ||
lines = value.split(/(?<=\\n)/); | ||
} | ||
} | ||
@@ -181,0 +191,0 @@ |
{ | ||
"name": "gettext-parser", | ||
"description": "Parse and compile gettext po and mo files to/from json, nothing more, nothing less", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"author": "Andris Reinman", | ||
@@ -37,4 +37,4 @@ "contributors": [ | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^5.1.1", | ||
"mocha": "^9.1.3" | ||
"eslint-plugin-promise": "^5.2.0", | ||
"mocha": "^9.2.1" | ||
}, | ||
@@ -41,0 +41,0 @@ "keywords": [ |
@@ -71,2 +71,3 @@ gettext-parser [![ci](https://github.com/smhg/gettext-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/smhg/gettext-parser/actions/workflows/ci.yml) | ||
If a comparator function is provided, that function will be used to sort entries in the output. The function is called with two arguments, each of which is a single message entry with the structure described below. The function should follow the standard rules for functions passed to `Array.sort()`: return `0` if the entries are interchangeable in sort order; return a number less than 0 if the first entry should come before the second one; and return a number greater than 0 if the second entry should come before the first one. | ||
* **escapeCharacters** (boolean) - (default `true`) if `false`, will skip escape newlines and quotes characters functionality. | ||
@@ -73,0 +74,0 @@ **Example** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52887
1248
207