Comparing version 2.3.0 to 3.0.0
158
lib/html.js
(function() { | ||
'use strict'; | ||
var CND, Cupofjoe, DATOM, MAIN, alert, assign, badge, debug, echo, excluded_content_parts, freeze, help, info, is_frozen, isa, jr, lets, log, new_datom, rpr, select, thaw, type_of, types, urge, validate, warn, whisper, | ||
var CND, Cupofjoe, DATOM, alert, assign, badge, debug, echo, excluded_content_parts, freeze, help, info, is_frozen, isa, jr, lets, log, new_datom, rpr, select, thaw, type_of, types, urge, validate, warn, whisper, | ||
indexOf = [].indexOf; | ||
@@ -236,3 +236,3 @@ | ||
/* TAINT ^^^ ??? ^^^ */ | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.$html_from_datoms = function() { | ||
@@ -257,3 +257,3 @@ var $; | ||
this._html_from_datom = function(d) { | ||
var atxt, i, is_empty_tag, key, len, ref, ref1, ref2, ref3, sigil, slash, src, tagname, value, x_key, x_sys_key; | ||
var atxt, bnl, i, is_block_tag, is_empty_tag, key, len, ref, ref1, ref2, ref3, ref4, sigil, slash, src, tagname, value, x_key, x_sys_key, xnl; | ||
if (isa.text(d)) { | ||
@@ -268,2 +268,5 @@ return this._html_from_datom((this.text(d))[0]); | ||
x_key = null; | ||
is_block_tag = (ref = d.$blk) != null ? ref : false; | ||
bnl = is_block_tag ? '\n\n' : ''/* TAINT make configurable */ | ||
xnl = '\n'/* TAINT make configurable */ | ||
//......................................................................................................... | ||
@@ -286,12 +289,12 @@ /* TAINT simplistic solution; namespace might already be taken? */ | ||
//......................................................................................................... | ||
return this._escape_text((ref = d.text) != null ? ref : ''); | ||
return this._escape_text((ref1 = d.text) != null ? ref1 : ''); | ||
} | ||
if ((sigil === '^') && (tagname === 'raw')) { | ||
return (ref1 = d.text) != null ? ref1 : ''; | ||
return (ref2 = d.text) != null ? ref2 : ''; | ||
} | ||
if ((sigil === '^') && (tagname === 'doctype')) { | ||
return `<!DOCTYPE ${(ref2 = d.$value) != null ? ref2 : 'html'}>`; | ||
return `<!DOCTYPE ${(ref3 = d.$value) != null ? ref3 : 'html'}>${xnl}`; | ||
} | ||
if (sigil === '>') { | ||
return `</${tagname}>`; | ||
return `</${tagname}>${bnl}`; | ||
} | ||
@@ -308,5 +311,5 @@ //......................................................................................................... | ||
} | ||
ref3 = (Object.keys(src)).sort(); | ||
for (i = 0, len = ref3.length; i < len; i++) { | ||
key = ref3[i]; | ||
ref4 = (Object.keys(src)).sort(); | ||
for (i = 0, len = ref4.length; i < len; i++) { | ||
key = ref4[i]; | ||
if (key.startsWith('$')) { | ||
@@ -323,3 +326,3 @@ continue; | ||
/* TAINT make self-closing elements configurable, depend on HTML5 type */ | ||
slash = (sigil === '<') || is_empty_tag ? '' : `</${tagname}>`; | ||
slash = (sigil === '<') || is_empty_tag ? '' : `</${tagname}>${bnl}`; | ||
x_sys_key = x_key != null ? `<x-sys-key>${x_key}</x-sys-key>` : ''; | ||
@@ -332,137 +335,4 @@ if (atxt === '') { | ||
//=========================================================================================================== | ||
// HTML SPECIALS | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.raw = function(text) { | ||
var arity; | ||
if ((arity = arguments.length) !== 1) { | ||
throw new Error(`^intertext/raw@1801^ expected 1 argument, got ${arity}`); | ||
} | ||
validate.text(text); | ||
return [new_datom('^raw', {text})]; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.text = function(text) { | ||
var arity; | ||
if ((arity = arguments.length) !== 1) { | ||
throw new Error(`^intertext/text@2368^ expected 1 argument, got ${arity}`); | ||
} | ||
validate.text(text); | ||
return [new_datom('^text', {text})]; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.css = function(href) { | ||
/* Creates a list with one datom representing a stylesheet link: `<link rel=stylesheet | ||
href="../reset.css"/>` | ||
*/ | ||
var arity; | ||
if ((arity = arguments.length) !== 1) { | ||
throw new Error(`^intertext/css@2935^ expected 1 argument, got ${arity}`); | ||
} | ||
validate.nonempty_text(href); | ||
return [ | ||
new_datom('^link', | ||
{ | ||
rel: 'stylesheet', | ||
href | ||
}) | ||
]; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.script = function(x) { | ||
var arity, type; | ||
if ((arity = arguments.length) !== 1) { | ||
throw new Error(`^intertext/script@3502^ expected 1 argument, got ${arity}`); | ||
} | ||
switch (type = type_of(x)) { | ||
case 'text': | ||
return this._script_src(x); | ||
case 'function': | ||
return this._script_literal(x); | ||
} | ||
throw new Error(`^intertext/script@4069^ expected a text or a function, got a ${type}`); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._script_src = function(src) { | ||
/* Creates a list with one datom representing a script tag: `<script type="text/javascript" | ||
src="../jquery-3.4.1.js">` | ||
*/ | ||
validate.nonempty_text(src); | ||
return [new_datom('^script', {src})]; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._script_literal = function(f) { | ||
/* Creates a list with three datoms representing a script tag with embedded JavaScript source text: | ||
``` | ||
<script type="text/javascript"> | ||
var a, b; | ||
a = 42; | ||
b = a * 2; | ||
</script>` | ||
*/ | ||
return [new_datom('<script'), this._as_iife(f), new_datom('>script')]; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._as_iife = function(f) { | ||
var R; | ||
R = `(${f.toString()})();`; | ||
return (this.raw(R))[0]; | ||
}; | ||
//=========================================================================================================== | ||
// CUP OF HTML | ||
//----------------------------------------------------------------------------------------------------------- | ||
MAIN = this/* TAINT won't work with configured instances of HTML */ | ||
this.Cupofhtml = class Cupofhtml extends Cupofjoe { | ||
// @include CUPOFHTML, { overwrite: false, } | ||
// @extend MAIN, { overwrite: false, } | ||
//--------------------------------------------------------------------------------------------------------- | ||
constructor(settings = null) { | ||
super({...{ | ||
flatten: true | ||
}, ...settings}); | ||
return this; | ||
} | ||
//--------------------------------------------------------------------------------------------------------- | ||
tag(tagname, ...content) { | ||
if (tagname == null) { | ||
return this.cram(...content); | ||
} | ||
if (content.length === 0) { | ||
/* TAINT allow extended syntax, attributes */ | ||
return this.cram(new_datom(`^${tagname}`)); | ||
} | ||
return this.cram(new_datom(`<${tagname}`), ...content, new_datom(`>${tagname}`)); | ||
} | ||
//--------------------------------------------------------------------------------------------------------- | ||
text(...P) { | ||
return this.cram(MAIN.text(...P)); | ||
} | ||
raw(...P) { | ||
return this.cram(MAIN.raw(...P)); | ||
} | ||
script(...P) { | ||
return this.cram(MAIN.script(...P)); | ||
} | ||
css(...P) { | ||
return this.cram(MAIN.css(...P)); | ||
} | ||
}; | ||
}).call(this); | ||
//# sourceMappingURL=html.js.map |
(function() { | ||
'use strict'; | ||
var CND, FS, Html, Hyph, INTERTEXT, Intertext, MAIN, Multimix, PATH, Patterns, Slabs, Tbl, Ucd, alert, assign, badge, cast, debug, echo, help, info, inspect, isa, jr, log, rpr, type_of, urge, validate, warn, whisper; | ||
var CND, Cupofhtml, FS, Html, Hyph, INTERTEXT, Intertext, MAIN, Multimix, PATH, Patterns, Slabs, Tbl, Ucd, alert, assign, badge, cast, debug, echo, help, info, inspect, isa, jr, log, rpr, type_of, urge, validate, warn, whisper; | ||
@@ -64,2 +64,12 @@ //########################################################################################################### | ||
Cupofhtml = (function() { | ||
//----------------------------------------------------------------------------------------------------------- | ||
class Cupofhtml extends Multimix {}; | ||
Cupofhtml.include(require('./cupofhtml')); | ||
return Cupofhtml; | ||
}).call(this); | ||
Hyph = (function() { | ||
@@ -162,2 +172,3 @@ //----------------------------------------------------------------------------------------------------------- | ||
this.HTML = new Html(); | ||
this.CUPOFHTML = new Cupofhtml(); | ||
this.HYPH = new Hyph(); | ||
@@ -164,0 +175,0 @@ this.UCD = new Ucd(); |
{ | ||
"name": "intertext", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"description": "Services for Recurrent Text-related Tasks", | ||
@@ -35,3 +35,3 @@ "main": "lib/main.js", | ||
"cupofjoe": "^0.1.1", | ||
"datom": "^6.1.1", | ||
"datom": "^7.0.0", | ||
"hyphenopoly": "^4.5.0", | ||
@@ -38,0 +38,0 @@ "intertype": "^7.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
693009
59
5320
+ Addeddatom@7.1.0(transitive)
+ Addedemittery@0.6.0(transitive)
- Removeddatom@6.3.0(transitive)
- Removedemittery@0.7.2(transitive)
- Removedletsfreezethat@2.2.5(transitive)
Updateddatom@^7.0.0