@jdeighan/coffee-utils 14.0.33 → 14.0.34
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/html.coffee +9 -1
- package/src/html.js +10 -1
package/package.json
CHANGED
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 '>'
|