Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intertext

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intertext - npm Package Compare versions

Comparing version 0.5.7 to 1.0.0

lib/mkts.js

115

lib/html.js
(function() {
'use strict';
var CND, DATOM, HtmlParser, alert, badge, debug, echo, find_next_tag, help, info, isa, jr, lets, log, new_datom, rpr, select, type_of, types, urge, validate, warn, whisper,
var CND, DATOM, HtmlParser, alert, assign, badge, debug, echo, help, info, isa, jr, lets, log, new_datom, rpr, select, type_of, types, urge, validate, warn, whisper,
indexOf = [].indexOf;

@@ -54,2 +54,4 @@

assign = Object.assign;
//===========================================================================================================

@@ -149,2 +151,12 @@

//-----------------------------------------------------------------------------------------------------------
this.$datom_as_html = () => {
var $;
({$} = (require('steampipes')).export());
return $((d, send) => {
send(this.datom_as_html(d));
return null;
});
};
//===========================================================================================================

@@ -214,88 +226,2 @@ // PARSING

//-----------------------------------------------------------------------------------------------------------
find_next_tag = function(text, prv_idx = 0) {
var idx_0, idx_1, idx_2;
idx_0 = text.indexOf('<', prv_idx);
idx_1 = text.indexOf('>', prv_idx);
if (idx_0 < 0) {
if (idx_1 < 0) {
return [null, null];
}
throw new Error("Syntax error: closing but no opening bracket");
}
if (idx_1 < 0) {
throw new Error("Syntax error: opening but no closing bracket");
}
if (idx_1 < idx_0) {
throw new Error("Syntax error: closing before opening bracket");
}
if (idx_1 < idx_0 + 2) {
throw new Error("Syntax error: closing bracket too close to opening bracket");
}
if (/\s/.test(text[idx_0 + 1])) {
throw new Error("Syntax error: whitespace not allowed here");
}
idx_2 = text.indexOf('<', idx_0 + 1);
if ((0 < idx_2 && idx_2 < idx_1)) {
throw new Error("Syntax error: additional opening bracket");
}
return [idx_0, idx_1];
};
//-----------------------------------------------------------------------------------------------------------
this.mkts_html_as_datoms = function(text) {
var R, d, error, idx_0, idx_1, prv_idx, prv_idx_1, source, tags;
R = [];
prv_idx = 0;
prv_idx_1 = -1;
while (true) {
try {
//.......................................................................................................
//.........................................................................................................
[idx_0, idx_1] = find_next_tag(text, prv_idx);
} catch (error1) {
error = error1;
if (!/Syntax error/.test(error.message)) {
throw error;
}
source = text.slice(prv_idx);
R.push(new_datom('~error', {
message: `${error.message}: ${jr(source)}`,
type: 'mkts-syntax-html',
source: source
}));
return R;
}
//.......................................................................................................
if (idx_0 > prv_idx_1 + 1) {
R.push(new_datom('^text', {
text: text.slice(prv_idx_1 + 1, idx_0)
}));
}
if (idx_0 == null) {
break;
}
tags = this.html_as_datoms(text.slice(idx_0, +idx_1 + 1 || 9e9));
if (text[idx_1 - 1] === '/') {
R.push(d = lets(tags[0], function(d) {
return d.$key = '^' + d.$key.slice(1);
}));
} else {
R.push(...tags);
}
prv_idx_1 = idx_1;
prv_idx = idx_1 + 1;
}
//.........................................................................................................
// debug '7776^', rpr { prv_idx, prv_idx_1, idx_0, idx_1, length: text.length, }
if (prv_idx < text.length) {
R.push(new_datom('^text', {
text: text.slice(prv_idx_1 + 1)
}));
}
return R;
};
//===========================================================================================================
// PARSING
//-----------------------------------------------------------------------------------------------------------
this.$html_as_datoms = function() {

@@ -315,17 +241,2 @@ var $;

//-----------------------------------------------------------------------------------------------------------
this.$mkts_html_as_datoms = function() {
var $;
({$} = (require('steampipes')).export());
return $((buffer_or_text, send) => {
var d, i, len, ref;
ref = this.mkts_html_as_datoms(buffer_or_text);
for (i = 0, len = ref.length; i < len; i++) {
d = ref[i];
send(d);
}
return null;
});
};
//###########################################################################################################

@@ -332,0 +243,0 @@ if (module === require.main) {

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 2.5.0
(function() {

@@ -101,1 +102,3 @@ 'use strict';

}).call(this);
//# sourceMappingURL=hyphenation.js.map

@@ -65,2 +65,3 @@ (function() {

this.HTML = require('./html');
this.MKTS = require('./mkts');
this.HYPH = require('./hyphenation');

@@ -67,0 +68,0 @@ this.SLABS = require('./slabs');

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 2.5.0
(function() {

@@ -157,1 +158,3 @@ 'use strict';

}).call(this);
//# sourceMappingURL=slabs.js.map

@@ -1107,298 +1107,2 @@ (function() {

//-----------------------------------------------------------------------------------------------------------
this["HTML.mkts_html_as_datoms"] = async function(T, done) {
var error, i, len, matcher, probe, probes_and_matchers;
probes_and_matchers = [
[
"line A<br/>line B",
[
{
"text": "line A",
"$key": "^text"
},
{
"$key": "^br"
},
{
"text": "line B",
"$key": "^text"
}
],
null
],
[
"<p>|here and|<br>",
[
{
"$key": "<p"
},
{
"text": "|here and|",
"$key": "^text"
},
{
"$key": "<br"
}
],
null
],
[
"|foo |<p>|here and|<br>|there|",
[
{
"text": "|foo |",
"$key": "^text"
},
{
"$key": "<p"
},
{
"text": "|here and|",
"$key": "^text"
},
{
"$key": "<br"
},
{
"text": "|there|",
"$key": "^text"
}
],
null
],
[
"< >",
[
{
"message": "Syntax error: whitespace not allowed here: \"< >\"",
"type": "mkts-syntax-html",
"source": "< >",
"$key": "~error"
}
],
null
],
[
"< x >",
[
{
"message": "Syntax error: whitespace not allowed here: \"< x >\"",
"type": "mkts-syntax-html",
"source": "< x >",
"$key": "~error"
}
],
null
],
[
"<>",
[
{
"message": "Syntax error: closing bracket too close to opening bracket: \"<>\"",
"type": "mkts-syntax-html",
"source": "<>",
"$key": "~error"
}
],
null
],
[
"<",
[
{
"message": "Syntax error: opening but no closing bracket: \"<\"",
"type": "mkts-syntax-html",
"source": "<",
"$key": "~error"
}
],
null
],
[
"<tag",
[
{
"message": "Syntax error: opening but no closing bracket: \"<tag\"",
"type": "mkts-syntax-html",
"source": "<tag",
"$key": "~error"
}
],
null
],
[
"tag>",
[
{
"message": "Syntax error: closing but no opening bracket: \"tag>\"",
"type": "mkts-syntax-html",
"source": "tag>",
"$key": "~error"
}
],
null
],
[
">",
[
{
"message": "Syntax error: closing but no opening bracket: \">\"",
"type": "mkts-syntax-html",
"source": ">",
"$key": "~error"
}
],
null
],
[
"<",
[
{
"message": "Syntax error: opening but no closing bracket: \"<\"",
"type": "mkts-syntax-html",
"source": "<",
"$key": "~error"
}
],
null
],
[
"x",
[
{
"text": "x",
"$key": "^text"
}
],
null
],
[
"&",
[
{
"text": "&",
"$key": "^text"
}
],
null
],
[
"&;",
[
{
"text": "&;",
"$key": "^text"
}
],
null
],
[
"&&",
[
{
"text": "&&",
"$key": "^text"
}
],
null
],
[
"max & moritz",
[
{
"text": "max & moritz",
"$key": "^text"
}
],
null
],
[
"&amp;",
[
{
"text": "&amp;",
"$key": "^text"
}
],
null
],
[
"<tag>\n \n\t\n</p>",
[
{
"$key": "<tag"
},
{
"text": "\n \n\t\n",
"$key": "^text"
},
{
"$key": ">p"
}
],
null
],
[
"<tag a='<'>",
[
{
"message": "Syntax error: additional opening bracket: \"<tag a='<'>\"",
"type": "mkts-syntax-html",
"source": "<tag a='<'>",
"$key": "~error"
}
],
null
],
[
"<tag a='>'>",
[
{
"text": ">",
"$key": "^text"
},
{
"message": "Syntax error: closing but no opening bracket: \"'>\"",
"type": "mkts-syntax-html",
"source": "'>",
"$key": "~error"
}
],
null
],
[
"if <math> a > b </math> then",
[
{
"text": "if ",
"$key": "^text"
},
{
"$key": "<math"
},
{
"message": "Syntax error: closing before opening bracket: \" a > b </math> then\"",
"type": "mkts-syntax-html",
"source": " a > b </math> then",
"$key": "~error"
}
],
null
]
];
for (i = 0, len = probes_and_matchers.length; i < len; i++) {
[probe, matcher, error] = probes_and_matchers[i];
await T.perform(probe, matcher, error, function() {
return new Promise(function(resolve, reject) {
var text;
text = probe;
return resolve(HTML.mkts_html_as_datoms(text));
});
});
}
//.........................................................................................................
done();
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["HTML.html_as_datoms (2)"] = async function(T, done) {

@@ -1481,53 +1185,3 @@ var error, i, len, matcher, probe, probes_and_matchers;

//-----------------------------------------------------------------------------------------------------------
this["HTML.$mkts_html_as_datoms"] = function(T, done) {
var $, $async, $drain, $show, $watch, SP, matcher, pipeline, probe;
SP = require('steampipes');
// SP = require '../../apps/steampipes'
({$, $async, $drain, $watch, $show} = SP.export());
//.........................................................................................................
probe = `<p>A <em>concise</em> introduction to the things discussed below.</p>`;
matcher = [
{
"$key": "<p"
},
{
"text": "A ",
"$key": "^text"
},
{
"$key": "<em"
},
{
"text": "concise",
"$key": "^text"
},
{
"$key": ">em"
},
{
"text": " introduction to the things discussed below.",
"$key": "^text"
},
{
"$key": ">p"
}
];
//.........................................................................................................
pipeline = [];
pipeline.push([Buffer.from(probe)]);
pipeline.push(SP.$split());
pipeline.push(HTML.$mkts_html_as_datoms());
pipeline.push($show());
pipeline.push($drain((result) => {
help(jr(result));
T.eq(result, matcher);
return done();
}));
SP.pull(...pipeline);
//.........................................................................................................
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["demo"] = function(T, done) {
this["HTML demo"] = function(T, done) {
var d, datoms, i, len, ref, text;

@@ -1566,3 +1220,3 @@ text = `<!DOCTYPE html>

//-----------------------------------------------------------------------------------------------------------
this["demo (buffer)"] = function(T, done) {
this["HTML demo (buffer)"] = function(T, done) {
var buffer, d, datoms, i, len, ref, text;

@@ -1603,20 +1257,3 @@ text = `<!DOCTYPE html>

// test @[ "demo" ]
// test @[ "demo (buffer)" ]
// test @[ "HTML.$html_as_datoms" ]
// test @[ "must quote attribute value" ]
// test @[ "DATOM.HTML._as_attribute_literal" ]
// test @[ "isa.intertext_html_tagname" ]
// test @[ "HTML.datom_as_html (singular tags)" ]
// test @[ "HTML.datom_as_html (closing tags)" ]
// test @[ "HTML.datom_as_html (opening tags)" ]
// test @[ "HTML.datom_as_html (texts)" ]
// test @[ "HTML.datom_as_html (opening tags w/ $value)" ]
// test @[ "HTML.datom_as_html (system tags)" ]
// test @[ "HTML.datom_as_html (raw pseudo-tag)" ]
// test @[ "HTML.datom_as_html (doctype)" ]
// test @[ "HTML.html_as_datoms (1)" ]
// test @[ "HTML.html_as_datoms (dubious 2)" ]
// test @[ "HTML.html_as_datoms (dubious w/ pre-processor)" ]
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 2.5.0
(function() {

@@ -146,1 +147,3 @@ 'use strict';

}).call(this);
//# sourceMappingURL=hyphenation.test.js.map

@@ -1,2 +0,1 @@

// Generated by CoffeeScript 2.5.0
(function() {

@@ -57,3 +56,3 @@ //###########################################################################################################

// debug '39838', path, key
throw new Error(`duplicate key ${rpr(key)}`);
throw new Error(`duplicate key ${rpr(key)} in ${path}`);
}

@@ -69,3 +68,1 @@ L[key] = value.bind(L);

}).call(this);
//# sourceMappingURL=main.js.map

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 2.5.0
(function() {

@@ -261,1 +262,3 @@ 'use strict';

}).call(this);
//# sourceMappingURL=slabs.test.js.map

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 2.5.0
(function() {

@@ -276,1 +277,3 @@ 'use strict';

}).call(this);
//# sourceMappingURL=types.js.map
{
"name": "intertext",
"version": "0.5.7",
"version": "1.0.0",
"description": "Services for Recurrent Text-related Tasks",
"main": "lib/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "coffee --map -o lib -c src",
"test": "npm run build && node lib/tests/main.js"
},

@@ -9,0 +10,0 @@ "repository": {

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc