@jdeighan/coffee-utils 14.0.33 → 14.0.35
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -4
- package/src/html.coffee +9 -1
- package/src/html.js +10 -1
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "14.0.
|
4
|
+
"version": "14.0.35",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
@@ -45,14 +45,14 @@
|
|
45
45
|
},
|
46
46
|
"homepage": "https://github.com/johndeighan/coffee-utils#readme",
|
47
47
|
"dependencies": {
|
48
|
-
"@jdeighan/base-utils": "^4.0.
|
48
|
+
"@jdeighan/base-utils": "^4.0.21",
|
49
49
|
"cross-env": "^7.0.3",
|
50
50
|
"n-readlines": "^1.0.1",
|
51
51
|
"readline-sync": "^1.4.10",
|
52
52
|
"svelte": "^3.55.1"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
|
-
"@jdeighan/unit-tester": "^3.0.
|
56
|
-
"ava": "^5.
|
55
|
+
"@jdeighan/unit-tester": "^3.0.42",
|
56
|
+
"ava": "^5.2.0"
|
57
57
|
}
|
58
58
|
}
|
package/src/html.coffee
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
4
|
import {
|
5
|
-
undef,
|
5
|
+
undef, defined, notdefined, words, isEmpty, nonEmpty,
|
6
|
+
toBlock, OL, getOptions,
|
6
7
|
} from '@jdeighan/base-utils'
|
7
8
|
import {dbgEnter, dbgReturn, dbg} from '@jdeighan/base-utils/debug'
|
8
9
|
import {indented} from '@jdeighan/coffee-utils/indent'
|
@@ -222,7 +223,14 @@ export formatHTML = (html, hOptions={}) =>
|
|
222
223
|
oneIndent: ' '
|
223
224
|
})
|
224
225
|
|
226
|
+
if (notdefined(html))
|
227
|
+
dbgReturn 'formatHTML', ''
|
228
|
+
return ''
|
225
229
|
html = html.trim() # remove any leading/trailing whitespace
|
230
|
+
if (html == '')
|
231
|
+
dbgReturn 'formatHTML', ''
|
232
|
+
return ''
|
233
|
+
|
226
234
|
assert html.charAt(0) == '<', "Bad HTML, no < at start"
|
227
235
|
assert html.charAt(html.length-1) == '>', "Bad HTML, no > at end"
|
228
236
|
|
package/src/html.js
CHANGED
@@ -9,7 +9,8 @@ import {
|
|
9
9
|
|
10
10
|
import {
|
11
11
|
undef,
|
12
|
-
|
12
|
+
defined,
|
13
|
+
notdefined,
|
13
14
|
words,
|
14
15
|
isEmpty,
|
15
16
|
nonEmpty,
|
@@ -230,7 +231,15 @@ export var formatHTML = (html, hOptions = {}) => {
|
|
230
231
|
({oneIndent} = getOptions(hOptions, {
|
231
232
|
oneIndent: ' '
|
232
233
|
}));
|
234
|
+
if (notdefined(html)) {
|
235
|
+
dbgReturn('formatHTML', '');
|
236
|
+
return '';
|
237
|
+
}
|
233
238
|
html = html.trim(); // remove any leading/trailing whitespace
|
239
|
+
if (html === '') {
|
240
|
+
dbgReturn('formatHTML', '');
|
241
|
+
return '';
|
242
|
+
}
|
234
243
|
assert(html.charAt(0) === '<', "Bad HTML, no < at start");
|
235
244
|
assert(html.charAt(html.length - 1) === '>', "Bad HTML, no > at end");
|
236
245
|
// --- Remove leading '<' and trailing '>'
|