Socket
Socket
Sign inDemoInstall

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 1.5.0 to 1.6.0

47

lib/tabulate.js
// Generated by CoffeeScript 2.5.1
(function() {
//###########################################################################################################
var $, $as_event, $as_row, $async, $cleanup, $dividers_bottom, $dividers_top, $drain, $set_widths_etc, $show, $watch, CND, DATOM, SP, _new_state, alert, as_row, as_text, assign, badge, boxes, cast, copy, debug, freeze, get_divider, help, isa, jr, keys_toplevel, last_of, lets, new_datom, rpr, select, to_width, type_of, types, urge, validate, values_alignment, values_overflow, warn, width_of, wrap_datom;
var $, $as_event, $as_row, $async, $cleanup, $dividers_bottom, $dividers_top, $drain, $set_widths_etc, $show, $watch, CND, DATOM, SP, _new_state, alert, as_row, as_text, assign, badge, boxes, cast, copy, debug, freeze, get_divider, help, inspect, isa, jr, keys_toplevel, last_of, lets, new_datom, rpr, rpr_settings, select, to_width, type_of, types, urge, validate, values_alignment, values_overflow, warn, width_of, wrap_datom;
CND = require('cnd');
rpr = CND.rpr;
badge = 'INTERTEXT/TBL';

@@ -47,2 +45,4 @@

({inspect} = require('util'));
//-----------------------------------------------------------------------------------------------------------

@@ -450,2 +450,25 @@ this.$tabulate = function(settings = {}) {

//-----------------------------------------------------------------------------------------------------------
/* TAINT this is a temporary local copy of the method defined in the `main` submodule; in the future,
both functions should be unified. */
rpr = function(...P) {
var x;
return ((function() {
var i, len, results;
results = [];
for (i = 0, len = P.length; i < len; i++) {
x = P[i];
results.push(inspect(x, rpr_settings));
}
return results;
})()).join(' ');
};
rpr_settings = {
depth: 2e308,
maxArrayLength: 2e308,
breakLength: 2e308,
compact: true
};
//-----------------------------------------------------------------------------------------------------------
as_text = function(S, x) {

@@ -463,13 +486,7 @@ var type;

type = type_of(x);
if (type === 'nan') {
return 'NaN';
}
if (type === 'infinity') {
if (type === 'nan' || type === 'nan' || type === 'infinity' || type === 'object' || type === 'list' || type === 'number') {
return rpr(x);
}
if (type === 'object' || type === 'list' || type === 'number') {
return jr(x);
}
if (type !== 'text') {
return jr(x);
return rpr(x);
}

@@ -484,10 +501,2 @@ x = x.replace(/\n/g, '⏎');

// switch
// when 'text'
// return x if S.multiline
// return jr x
// return x unless ( x is '' ) or ( /\s/.test x )
// ### other types, number formatting go here ###
// return rpr x
//-----------------------------------------------------------------------------------------------------------

@@ -494,0 +503,0 @@ copy = function(x) {

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

// Generated by CoffeeScript 2.5.1
(function() {

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

}).call(this);
//# sourceMappingURL=basics.test.js.map
// Generated by CoffeeScript 2.5.1
(function() {
/*
// ###
====================================================================================
compact names for MKTScript:
// ====================================================================================
// compact names for MKTScript:
`<div#c432.foo.bar>...</div>` => `<div id=c432 class='foo bar'>...</div>`
`<p.noindent>...</p>` => `<p class=noindent>...</p>`
// `<div#c432.foo.bar>...</div>` => `<div id=c432 class='foo bar'>...</div>`
// `<p.noindent>...</p>` => `<p class=noindent>...</p>`
positional arguments:
`<columns:2>` => `<columns count=2/>` => `<columns count=2></columns>` ?=> `<mkts-columns count=2></mkts-columns>`
// positional arguments:
// `<columns:2>` => `<columns count=2/>` => `<columns count=2></columns>` ?=> `<mkts-columns count=2></mkts-columns>`
NB Svelte uses capitalized names, allows self-closing tags(!): `<Mytag/>`
// NB Svelte uses capitalized names, allows self-closing tags(!): `<Mytag/>`
*/
'use strict';
var CND, DATOM, INTERTEXT, MKTS, alert, badge, debug, echo, help, info, isa, jr, lets, log, new_datom, rpr, select, test, type_of, types, urge, validate, warn, whisper;
// ###
//###########################################################################################################
CND = require('cnd');
// 'use strict'
rpr = CND.rpr;
// ############################################################################################################
// CND = require 'cnd'
// rpr = CND.rpr
// badge = 'INTERTEXT/TESTS/MKTSCRIPT'
// log = CND.get_logger 'plain', badge
// info = CND.get_logger 'info', badge
// whisper = CND.get_logger 'whisper', badge
// alert = CND.get_logger 'alert', badge
// debug = CND.get_logger 'debug', badge
// warn = CND.get_logger 'warn', badge
// help = CND.get_logger 'help', badge
// urge = CND.get_logger 'urge', badge
// echo = CND.echo.bind CND
// { jr, } = CND
// #...........................................................................................................
// DATOM = new ( require 'datom' ).Datom { dirty: false, }
// { new_datom
// lets
// select } = DATOM.export()
// types = require '../types'
// { isa
// validate
// # cast
// # declare
// # declare_cast
// # check
// # sad
// # is_sad
// # is_happy
// type_of } = types
// #...........................................................................................................
// test = require 'guy-test'
// INTERTEXT = require '../..'
// { MKTS, } = INTERTEXT
badge = 'INTERTEXT/TESTS/MKTSCRIPT';
// #===========================================================================================================
// # TESTS
// #-----------------------------------------------------------------------------------------------------------
// @[ "MKTS.datoms_from_html" ] = ( T, done ) ->
// 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 [ probe, matcher, error, ] in probes_and_matchers
// await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) ->
// text = probe
// resolve MKTS.datoms_from_html text
// #.........................................................................................................
// done()
// return null
log = CND.get_logger('plain', badge);
// #-----------------------------------------------------------------------------------------------------------
// @[ "MKTS.datoms_from_html (compact syntax)" ] = ( T, done ) ->
// probes_and_matchers = [
// # [ '<columns =2 =3>' ]
// ["<div>",[{"$key":"<div"}]]
// ["<div#c432.foo.bar>",[{"$key":"<div","id":"c432","class":"foo bar"}]]
// ["<p.noindent>",[{"$key":"<p","class":"noindent"}]]
// ]
// for [ probe, matcher, error, ] in probes_and_matchers
// await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) ->
// resolve MKTS.datoms_from_html probe
// #.........................................................................................................
// done()
// return null
info = CND.get_logger('info', badge);
// #-----------------------------------------------------------------------------------------------------------
// @[ "MKTS.$datoms_from_html" ] = ( T, done ) ->
// 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 MKTS.$datoms_from_html()
// pipeline.push $show()
// pipeline.push $drain ( result ) =>
// help jr result
// T.eq result, matcher
// done()
// SP.pull pipeline...
// #.........................................................................................................
// return null
whisper = CND.get_logger('whisper', badge);
// #-----------------------------------------------------------------------------------------------------------
// @[ "MKTS.datoms_from_html (dubious)" ] = ( T, done ) ->
// probes_and_matchers = [
// ### TAINT these edge cases should be solved by an appropriate (MKTScript) pre-processor; NB that in
// MKTScript stray pointy brackets in ordinary text (but not in `<code>` blocks) are forbidden and must
// be escaped as entities wherever they appear in attribute values; these rules, however, do not
// necessarily apply when parsing general MKTS sources. ###
// ###
// ["< >",[{"text":"< >","$key":"^text"}],null] # !!! silent failure
// ["< x >",[{"text":"< x >","$key":"^text"}],null] # !!! silent failure
// ["<>",[{"text":"<>","$key":"^text"}],null] # !!! silent failure
// ["<",[{"text":"<","$key":"^text"}],null] # !!! silent failure
// ["<tag",[{"text":"<tag","$key":"^text"}],null] # !!! silent failure
// ###
// ["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]
// [">",[{"message":"Syntax error: closing but no opening bracket: \">\"","type":"mkts-syntax-html","source":">","$key":"~error"}],null]
// ["&",[{"text":"&","$key":"^text"}],null]
// ["&amp;",[{"text":"&amp;","$key":"^text"}],null]
// ["<tag a='<'>",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// ]
// for [ probe, matcher, error, ] in probes_and_matchers
// await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) ->
// resolve MKTS.datoms_from_html probe
// #.........................................................................................................
// done()
// return null
alert = CND.get_logger('alert', badge);
// #-----------------------------------------------------------------------------------------------------------
// @[ "__MKTS.datoms_from_html (SGML SHORTTAG syntax)" ] = ( T, done ) ->
// provide_basic_parser.apply X = {}
// urge X._parse_html "<foo><br>content</foo>"
// urge X._parse_html "<foo#id.class>"
// urge X._parse_html "</foo>"
// urge X._parse_html "<tag>content</>"
// urge X._parse_html "<tag#id>content</>"
// urge X._parse_html "<tag/content/"
// urge X._parse_html "Yellow is <zh/黃/ <py/huang2/ in Mandarin."
// urge X._parse_html "Yellow is <zh/黃/> <py/huang2/> in Mandarin."
// urge X._parse_html "Yellow is <zh/黃> <py/huang2> in Mandarin."
// urge X._parse_html "China is big: <py|Zhongguo hen da.> in Mandarin."
// urge X._parse_html "a<py|huang2>b"
// urge X._parse_html "a<py|huang2 di4>b"
// # probes_and_matchers = [
// # ["<tag#id>content</>",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// # ["before<tag#id>content</>after",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// # ]
// # for [ probe, matcher, error, ] in probes_and_matchers
// # await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) ->
// # # resolve MKTS.datoms_from_html probe
// # resolve ( require '../html' ).datoms_from_html probe
// # #.........................................................................................................
// done()
// return null
debug = CND.get_logger('debug', badge);
// #-----------------------------------------------------------------------------------------------------------
// @[ "__MKTS.datoms_from_html (SGML NET syntax)" ] = ( T, done ) ->
// probes_and_matchers = [
// ["<tag#id/class/content/",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// ["before<tag#id/class/content/after",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// ]
// for [ probe, matcher, error, ] in probes_and_matchers
// await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) ->
// resolve MKTS.datoms_from_html probe
// #.........................................................................................................
// done()
// return null
warn = CND.get_logger('warn', badge);
// #===========================================================================================================
// # DEMOS
// #-----------------------------------------------------------------------------------------------------------
// @[ "MKTS demo" ] = ( T, done ) ->
// text = """<!DOCTYPE html>
// <h1#s4451><strong>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>
help = CND.get_logger('help', badge);
// <p#p227.noindent>However, the egg only got larger and larger, and <em>more and more human</em>:<br>
urge = CND.get_logger('urge', badge);
// when she had come within a few yards of it, she saw that it had eyes and a nose and mouth; and when she
// had come close to it, she saw clearly that it was <name ref=hd556>HUMPTY DUMPTY</name> himself. ‘It can’t
// be anybody else!’ she said to herself.<br/>
echo = CND.echo.bind(CND);
// ‘I’m as certain of it, as if his name were written all over his face.’
({jr} = CND);
// """
// for d in datoms = MKTS.datoms_from_html text
// echo jr d
// echo '-'.repeat 108
// echo result = ( MKTS.html_from_datoms d for d in datoms ).join ''
// # debug '^2228^', jr result
// T.eq result, "<!DOCTYPE html>\n<h1 id=s4451><strong>CHAPTER VI.</strong> \
// <name ref=hd553>Humpty Dumpty</h1>\n\n<p class=noindent id=p227>However, the egg only got larger and larger, \
// and <em>more and more human</em>:<br>\n\nwhen she had come within a few yards of it, she saw that it \
// had eyes and a nose and mouth; and when she\nhad come close to it, she saw clearly that it was \
// <name ref=hd556>HUMPTY DUMPTY</name> himself. ‘It can’t\nbe anybody else!’ she said to herself.\
// <br>\n\n‘I’m as certain of it, as if his name were written all over his face.’\n"
// #.........................................................................................................
// done()
// return null
//...........................................................................................................
DATOM = new (require('datom')).Datom({
dirty: false
});
// #-----------------------------------------------------------------------------------------------------------
// @[ "MKTS demo (buffer)" ] = ( T, done ) ->
// text = """<!DOCTYPE html>
// <h1#c4443><strong.myclass>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>"""
// buffer = Buffer.from text
// # debug '^80009^', buffer
// # for d in datoms = MKTS.datoms_from_html buffer
// for d in datoms = MKTS.datoms_from_html buffer
// echo jr d
// echo '-'.repeat 108
// echo result = ( MKTS.html_from_datoms d for d in datoms ).join ''
// T.eq result, "<!DOCTYPE html>\n<h1 id=c4443><strong class=myclass>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>"
// #.........................................................................................................
// done()
// return null
({new_datom, lets, select} = DATOM.export());
// ############################################################################################################
// if module is require.main then do => # await do =>
// # await @_demo()
// # await test @
// await test @[ "MKTS.datoms_from_html (SGML SHORTTAG syntax)" ]
// await test @[ "MKTS.datoms_from_html (SGML NET syntax)" ]
// # await test @[ "MKTS.datoms_from_html" ]
// # await test @[ "MKTS.datoms_from_html (compact syntax)" ]
// # await test @[ "MKTS.$datoms_from_html" ]
// # await test @[ "MKTS.datoms_from_html (dubious)" ]
// # await test @[ "MKTS demo" ]
// # await test @[ "MKTS demo (buffer)" ]
types = require('../types');
// cast
// declare
// declare_cast
// check
// sad
// is_sad
// is_happy
({isa, validate, type_of} = types);
//...........................................................................................................
test = require('guy-test');
INTERTEXT = require('../..');
({MKTS} = INTERTEXT);
//===========================================================================================================
// TESTS
//-----------------------------------------------------------------------------------------------------------
this["MKTS.datoms_from_html"] = 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(MKTS.datoms_from_html(text));
});
});
}
//.........................................................................................................
done();
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["MKTS.datoms_from_html (compact syntax)"] = async function(T, done) {
var error, i, len, matcher, probe, probes_and_matchers;
probes_and_matchers = [
[
// [ '<columns =2 =3>' ]
"<div>",
[
{
"$key": "<div"
}
]
],
[
"<div#c432.foo.bar>",
[
{
"$key": "<div",
"id": "c432",
"class": "foo bar"
}
]
],
[
"<p.noindent>",
[
{
"$key": "<p",
"class": "noindent"
}
]
]
];
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) {
return resolve(MKTS.datoms_from_html(probe));
});
});
}
//.........................................................................................................
done();
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["MKTS.$datoms_from_html"] = 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(MKTS.$datoms_from_html());
pipeline.push($show());
pipeline.push($drain((result) => {
help(jr(result));
T.eq(result, matcher);
return done();
}));
SP.pull(...pipeline);
//.........................................................................................................
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["MKTS.datoms_from_html (dubious)"] = async function(T, done) {
var error, i, len, matcher, probe, probes_and_matchers;
probes_and_matchers = [
[
/* TAINT these edge cases should be solved by an appropriate (MKTScript) pre-processor; NB that in
MKTScript stray pointy brackets in ordinary text (but not in `<code>` blocks) are forbidden and must
be escaped as entities wherever they appear in attribute values; these rules, however, do not
necessarily apply when parsing general MKTS sources. */
/*
["< >",[{"text":"< >","$key":"^text"}],null] # !!! silent failure
["< x >",[{"text":"< x >","$key":"^text"}],null] # !!! silent failure
["<>",[{"text":"<>","$key":"^text"}],null] # !!! silent failure
["<",[{"text":"<","$key":"^text"}],null] # !!! silent failure
["<tag",[{"text":"<tag","$key":"^text"}],null] # !!! silent failure
*/
"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
],
[
">",
[
{
"message": "Syntax error: closing but no opening bracket: \">\"",
"type": "mkts-syntax-html",
"source": ">",
"$key": "~error"
}
],
null
],
[
"&",
[
{
"text": "&",
"$key": "^text"
}
],
null
],
[
"&amp;",
[
{
"text": "&amp;",
"$key": "^text"
}
],
null
],
[
"<tag a='<'>",
[
{
"message": "Syntax error: additional opening bracket: \"<tag a='<'>\"",
"type": "mkts-syntax-html",
"source": "<tag a='<'>",
"$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) {
return resolve(MKTS.datoms_from_html(probe));
});
});
}
//.........................................................................................................
done();
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["__MKTS.datoms_from_html (SGML SHORTTAG syntax)"] = function(T, done) {
var X;
provide_basic_parser.apply(X = {});
urge(X._parse_html("<foo><br>content</foo>"));
urge(X._parse_html("<foo#id.class>"));
urge(X._parse_html("</foo>"));
urge(X._parse_html("<tag>content</>"));
urge(X._parse_html("<tag#id>content</>"));
urge(X._parse_html("<tag/content/"));
urge(X._parse_html("Yellow is <zh/黃/ <py/huang2/ in Mandarin."));
urge(X._parse_html("Yellow is <zh/黃/> <py/huang2/> in Mandarin."));
urge(X._parse_html("Yellow is <zh/黃> <py/huang2> in Mandarin."));
urge(X._parse_html("China is big: <py|Zhongguo hen da.> in Mandarin."));
urge(X._parse_html("a<py|huang2>b"));
urge(X._parse_html("a<py|huang2 di4>b"));
// probes_and_matchers = [
// ["<tag#id>content</>",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// ["before<tag#id>content</>after",[{"message":"Syntax error: additional opening bracket: \"<tag a='<'>\"","type":"mkts-syntax-html","source":"<tag a='<'>","$key":"~error"}],null]
// ]
// for [ probe, matcher, error, ] in probes_and_matchers
// await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) ->
// # resolve MKTS.datoms_from_html probe
// resolve ( require '../html' ).datoms_from_html probe
// #.........................................................................................................
done();
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["__MKTS.datoms_from_html (SGML NET syntax)"] = async function(T, done) {
var error, i, len, matcher, probe, probes_and_matchers;
probes_and_matchers = [
[
"<tag#id/class/content/",
[
{
"message": "Syntax error: additional opening bracket: \"<tag a='<'>\"",
"type": "mkts-syntax-html",
"source": "<tag a='<'>",
"$key": "~error"
}
],
null
],
[
"before<tag#id/class/content/after",
[
{
"message": "Syntax error: additional opening bracket: \"<tag a='<'>\"",
"type": "mkts-syntax-html",
"source": "<tag a='<'>",
"$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) {
return resolve(MKTS.datoms_from_html(probe));
});
});
}
//.........................................................................................................
done();
return null;
};
//===========================================================================================================
// DEMOS
//-----------------------------------------------------------------------------------------------------------
this["MKTS demo"] = function(T, done) {
var d, datoms, i, len, ref, result, text;
text = `<!DOCTYPE html>
<h1#s4451><strong>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>
<p#p227.noindent>However, the egg only got larger and larger, and <em>more and more human</em>:<br>
when she had come within a few yards of it, she saw that it had eyes and a nose and mouth; and when she
had come close to it, she saw clearly that it was <name ref=hd556>HUMPTY DUMPTY</name> himself. ‘It can’t
be anybody else!’ she said to herself.<br/>
‘I’m as certain of it, as if his name were written all over his face.’
`;
ref = datoms = MKTS.datoms_from_html(text);
for (i = 0, len = ref.length; i < len; i++) {
d = ref[i];
echo(jr(d));
}
echo('-'.repeat(108));
echo(result = ((function() {
var j, len1, results;
results = [];
for (j = 0, len1 = datoms.length; j < len1; j++) {
d = datoms[j];
results.push(MKTS.html_from_datoms(d));
}
return results;
})()).join(''));
// debug '^2228^', jr result
T.eq(result, "<!DOCTYPE html>\n<h1 id=s4451><strong>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>\n\n<p class=noindent id=p227>However, the egg only got larger and larger, and <em>more and more human</em>:<br>\n\nwhen she had come within a few yards of it, she saw that it had eyes and a nose and mouth; and when she\nhad come close to it, she saw clearly that it was <name ref=hd556>HUMPTY DUMPTY</name> himself. ‘It can’t\nbe anybody else!’ she said to herself.<br>\n\n‘I’m as certain of it, as if his name were written all over his face.’\n");
//.........................................................................................................
done();
return null;
};
//-----------------------------------------------------------------------------------------------------------
this["MKTS demo (buffer)"] = function(T, done) {
var buffer, d, datoms, i, len, ref, result, text;
text = `<!DOCTYPE html>
<h1#c4443><strong.myclass>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>`;
buffer = Buffer.from(text);
ref = datoms = MKTS.datoms_from_html(buffer);
// debug '^80009^', buffer
// for d in datoms = MKTS.datoms_from_html buffer
for (i = 0, len = ref.length; i < len; i++) {
d = ref[i];
echo(jr(d));
}
echo('-'.repeat(108));
echo(result = ((function() {
var j, len1, results;
results = [];
for (j = 0, len1 = datoms.length; j < len1; j++) {
d = datoms[j];
results.push(MKTS.html_from_datoms(d));
}
return results;
})()).join(''));
T.eq(result, "<!DOCTYPE html>\n<h1 id=c4443><strong class=myclass>CHAPTER VI.</strong> <name ref=hd553>Humpty Dumpty</h1>");
//.........................................................................................................
done();
return null;
};
//###########################################################################################################
if (module === require.main) {
(async() => { // await do =>
// await @_demo()
// await test @
await test(this["MKTS.datoms_from_html (SGML SHORTTAG syntax)"]);
return (await test(this["MKTS.datoms_from_html (SGML NET syntax)"]));
})();
}
// await test @[ "MKTS.datoms_from_html" ]
// await test @[ "MKTS.datoms_from_html (compact syntax)" ]
// await test @[ "MKTS.$datoms_from_html" ]
// await test @[ "MKTS.datoms_from_html (dubious)" ]
// await test @[ "MKTS demo" ]
// await test @[ "MKTS demo (buffer)" ]
}).call(this);
//# sourceMappingURL=mktscript.test.js.map

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

// Generated by CoffeeScript 2.5.1
(function() {

@@ -77,7 +76,8 @@ 'use strict';

return new Promise(async(resolve) => {
var $, $async, $drain, $show, $watch, SP, TBL, error, i, len, matcher, probe, probes_and_matchers, ref;
var $, $async, $drain, $show, $watch, INTERTEXT, SP, TBL, error, i, len, matcher, probe, probes_and_matchers, ref;
SP = require('steampipes');
({$, $async, $watch, $show, $drain} = SP.export());
//...........................................................................................................
TBL = (require('../..')).TBL;
INTERTEXT = require('../..');
TBL = INTERTEXT.TBL;
probes_and_matchers = [

@@ -91,28 +91,41 @@ [

return results;
}).apply(this)
}).apply(this),
[
void 0,
null,
2e308,
['text'],
{
foo: 'bar'
}
]
],
[
{
"text": "┌────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┐",
"$key": "^table"
text: '┌────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┐',
'$key': '^table'
},
{
"text": "│0 │1 │2 │3 │4 │5 │6 │",
"$key": "^table"
text: '│0 │1 │2 │3 │4 │5 │6 │',
'$key': '^table'
},
{
"text": "├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤",
"$key": "^table"
text: '├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤',
'$key': '^table'
},
{
"text": "│a │b │c │d │e │f │g │",
"$key": "^table"
text: '│a │b │c │d │e │f │g │',
'$key': '^table'
},
{
"text": "│1000000 │1000001 │1000002 │1000003 │1000004 │1000005 │1000006 │",
"$key": "^table"
text: '│1000000 │1000001 │1000002 │1000003 │1000004 │1000005 │1000006 │',
'$key': '^table'
},
{
"text": "└────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┘",
"$key": "^table"
text: "│○ │● │Infinity │[ 'text' ] │{ foo: 'bar…│○ │○ │",
'$key': '^table'
},
{
text: '└────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┘',
'$key': '^table'
}

@@ -137,2 +150,7 @@ ]

pipeline.push($drain(function(result) {
var j, len1, row;
for (j = 0, len1 = result.length; j < len1; j++) {
row = result[j];
echo(CND.gold(INTERTEXT.rpr(row)));
}
return resolve(result);

@@ -711,15 +729,14 @@ }));

// await @_xxx_kw_demo()
// test @
// test @[ "demo" ]
// test @[ "multiline text" ]
// test @[ "text representation" ]
return test(this["format callback"]);
return test(this);
})();
}
// for cid in [ 0 .. 32 ]
// test @[ "demo" ]
// test @[ "multiline text" ]
// test @[ "text representation" ]
// test @[ "format callback" ]
// test @demo
// for cid in [ 0 .. 32 ]
// debug ( cid.toString 16 ).padStart 4, '0'
}).call(this);
//# sourceMappingURL=tabulate.test.js.map
{
"name": "intertext",
"version": "1.5.0",
"version": "1.6.0",
"description": "Services for Recurrent Text-related Tasks",

@@ -34,10 +34,10 @@ "main": "lib/main.js",

"chevrotain": "^6.5.0",
"cnd": "^5.3.0",
"cnd": "^5.3.1",
"cupofjoe": "0.0.4",
"datom": "^3.0.1",
"hyphenopoly": "^4.1.0",
"intertype": "^3.1.2",
"datom": "^4.0.0",
"hyphenopoly": "^4.2.1",
"intertype": "^3.4.0",
"linebreak": "^1.0.2",
"multimix": "^2.1.6",
"steampipes": "^6.0.0",
"multimix": "^2.2.0",
"steampipes": "^6.1.1",
"term-size": "^2.2.0",

@@ -44,0 +44,0 @@ "to-width": "^1.0.3"

@@ -10,2 +10,3 @@

- [Related Links](#related-links)
- [To Do](#to-do)

@@ -48,1 +49,6 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update -->

## To Do
* [X] use `INTERTEXT.rpr()` for tabulation instead of `JSON.stringify()`

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 too big to display

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