@tim-greller/xgettext-regex 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/index.js +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,12 @@ ___________________
|
|
|
20
20
|
- Switched to **relative paths** for location comments to prohibit commiting personal workspace directory paths.
|
|
21
21
|
___________________
|
|
22
22
|
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm i @tim-greller/xgettext-regex
|
|
27
|
+
```
|
|
28
|
+
|
|
23
29
|
## Examples
|
|
24
30
|
|
|
25
31
|
```sh
|
package/index.js
CHANGED
|
@@ -81,13 +81,14 @@ function createDuplexStream (filename, opts) {
|
|
|
81
81
|
text = '"' + text.replace(/"/g, '\\"') + '"'
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// handle triple-quoted string (java
|
|
84
|
+
// handle triple-quoted string (java text blocks)
|
|
85
85
|
if (text.slice(0, 3) == '"""') {
|
|
86
86
|
text = text
|
|
87
87
|
.slice(3, -3)
|
|
88
|
-
|
|
89
|
-
.replace(
|
|
90
|
-
.replace(
|
|
88
|
+
// The following regexes use the double-negation [^\S\r\n] which corresponds to \s but excludes \r and \n.
|
|
89
|
+
.replace(/^\r?\n[^\S\r\n]*/, '') // remove initial new line
|
|
90
|
+
.replace(/\\\r?\n[^\S\r\n]*/g, '') // escaped linebreak + indent
|
|
91
|
+
.replace(/\r?\n[^\S\r\n]*/g, '\\n') // normal linebreak + indent
|
|
91
92
|
text = `"${text}"`
|
|
92
93
|
}
|
|
93
94
|
|