Comparing version 0.5.5 to 0.5.6
@@ -334,2 +334,62 @@ (function() { | ||
/* | ||
* #----------------------------------------------------------------------------------------------------------- | ||
* @html5_block_level_tagnames = new Set """address article aside blockquote dd details dialog div dl dt | ||
* fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr li main nav ol p pre section table | ||
* td th ul""".split /\s+/ | ||
* #----------------------------------------------------------------------------------------------------------- | ||
* @_new_datom = ( name, data, text ) -> | ||
* return new_datom '^text', { text, } if text? | ||
* #......................................................................................................... | ||
* is_block = @html5_block_level_tagnames.has name | ||
* unless data? | ||
* return new_datom '>' + name unless is_block | ||
* return new_datom '>' + name, { is_block, } | ||
* #......................................................................................................... | ||
* has_keys = false | ||
* for key, value of data | ||
* has_keys = true | ||
* data[ key ] = true if value is '' | ||
* #......................................................................................................... | ||
* unless has_keys | ||
* return new_datom '<' + name unless is_block | ||
* return new_datom '<' + name, { is_block, } | ||
* #......................................................................................................... | ||
* return new_datom '<' + name, { data, } unless is_block | ||
* return new_datom '<' + name, { data, is_block, } | ||
#----------------------------------------------------------------------------------------------------------- | ||
* @_new_parse_method = ( piecemeal ) -> | ||
* R = null | ||
* parser = new HtmlParser { preserveWS: true, } | ||
* #......................................................................................................... | ||
* parser.on 'data', ( { name, data, text, } ) => R.push @_new_datom name, data, text | ||
* parser.on 'error', ( error ) -> throw error | ||
* # parser.on 'end', -> R.push new_datom '^stop' | ||
* #......................................................................................................... | ||
* R = ( html ) => | ||
* R = [] | ||
* parser.write html | ||
* unless piecemeal | ||
* parser.flushText() | ||
* parser.reset() | ||
* return R | ||
* #......................................................................................................... | ||
* R.flush = -> parser.flushText() | ||
* R.reset = -> parser.reset() | ||
* return R | ||
#----------------------------------------------------------------------------------------------------------- | ||
class Htmlparser extends Multimix | ||
* @extend object_with_class_properties | ||
@include L | ||
#--------------------------------------------------------------------------------------------------------- | ||
constructor: ( @settings = null ) -> | ||
super() | ||
*/ | ||
}).call(this); |
@@ -953,2 +953,62 @@ (function() { | ||
/* | ||
#----------------------------------------------------------------------------------------------------------- | ||
probes_and_matchers = [ | ||
["<!DOCTYPE html>",[{"data":{"html":true},"$key":"<!DOCTYPE"}],null] | ||
["<title>MKTS</title>",[{"$key":"<title"},{"text":"MKTS","$key":"^text"},{"$key":">title"}],null] | ||
["<document/>",[{"$key":"<document"},{"$key":">document"}],null] | ||
["<foo bar baz=42>",[{"data":{"bar":true,"baz":"42"},"$key":"<foo"}],null] | ||
["<br/>",[{"$key":"<br"},{"$key":">br"}],null] | ||
["</thing>",[{"$key":">thing"}],null] | ||
["</foo>",[{"$key":">foo"}],null] | ||
["</document>",[{"$key":">document"}],null] | ||
["<title>MKTS</title>",[{"$key":"<title"},{"text":"MKTS","$key":"^text"},{"$key":">title"}],null] | ||
["<p foo bar=42>omg</p>",[{"data":{"foo":true,"bar":"42"},"is_block":true,"$key":"<p"},{"text":"omg","$key":"^text"},{"is_block":true,"$key":">p"}],null] | ||
["<document/><foo bar baz=42>something<br/>else</thing></foo>",[{"$key":"<document"},{"$key":">document"},{"data":{"bar":true,"baz":"42"},"$key":"<foo"},{"text":"something","$key":"^text"},{"$key":"<br"},{"$key":">br"},{"text":"else","$key":"^text"},{"$key":">thing"},{"$key":">foo"}],null] | ||
["<!DOCTYPE html><html lang=en><head><title>x</title></head><p data-x='<'>helo</p></html>",[{"data":{"html":true},"$key":"<!DOCTYPE"},{"data":{"lang":"en"},"$key":"<html"},{"$key":"<head"},{"$key":"<title"},{"text":"x","$key":"^text"},{"$key":">title"},{"$key":">head"},{"data":{"data-x":"<"},"is_block":true,"$key":"<p"},{"text":"helo","$key":"^text"},{"is_block":true,"$key":">p"},{"$key":">html"}],null] | ||
["<p foo bar=42><em>Yaffir stood high</em></p>",[{"data":{"foo":true,"bar":"42"},"is_block":true,"$key":"<p"},{"$key":"<em"},{"text":"Yaffir stood high","$key":"^text"},{"$key":">em"},{"is_block":true,"$key":">p"}],null] | ||
["<p foo bar=42><em><xxxxxxxxxxxxxxxxxxx>Yaffir stood high</p>",[{"data":{"foo":true,"bar":"42"},"is_block":true,"$key":"<p"},{"$key":"<em"},{"$key":"<xxxxxxxxxxxxxxxxxxx"},{"text":"Yaffir stood high","$key":"^text"},{"is_block":true,"$key":">p"}],null] | ||
["<p föö bär=42><em>Yaffir stood high</p>",[{"data":{"föö":true,"bär":"42"},"is_block":true,"$key":"<p"},{"$key":"<em"},{"text":"Yaffir stood high","$key":"^text"},{"is_block":true,"$key":">p"}],null] | ||
["<document 文=zh/><foo bar baz=42>something<br/>else</thing></foo>",[{"data":{"文":"zh"},"$key":"<document"},{"$key":">document"},{"data":{"bar":true,"baz":"42"},"$key":"<foo"},{"text":"something","$key":"^text"},{"$key":"<br"},{"$key":">br"},{"text":"else","$key":"^text"},{"$key":">thing"},{"$key":">foo"}],null] | ||
["<p foo bar=<>yeah</p>",[{"data":{"foo":true,"bar":"<"},"is_block":true,"$key":"<p"},{"text":"yeah","$key":"^text"},{"is_block":true,"$key":">p"}],null] | ||
["<p foo bar='<'>yeah</p>",[{"data":{"foo":true,"bar":"<"},"is_block":true,"$key":"<p"},{"text":"yeah","$key":"^text"},{"is_block":true,"$key":">p"}],null] | ||
["<p foo bar='<'>yeah</p>",[{"data":{"foo":true,"bar":"<"},"is_block":true,"$key":"<p"},{"text":"yeah","$key":"^text"},{"is_block":true,"$key":">p"}],null] | ||
["<<<<<",[{"text":"<<<<","$key":"^text"}],null] | ||
["something",[{"text":"something","$key":"^text"}],null] | ||
["else",[{"text":"else","$key":"^text"}],null] | ||
["<p>dangling",[{"is_block":true,"$key":"<p"},{"text":"dangling","$key":"^text"}],null] | ||
["𦇻𦑛𦖵𦩮𦫦𧞈",[{"text":"𦇻𦑛𦖵𦩮𦫦𧞈","$key":"^text"}],null] | ||
] | ||
#----------------------------------------------------------------------------------------------------------- | ||
show = ( html, datoms ) -> | ||
help CND.red html | ||
for d in datoms | ||
if d.text? | ||
info d.$key, ( CND.white jr d.text ) | ||
else | ||
if d.data? # and ( Object.keys d.data ).length > 0 | ||
info d.$key, ( CND.yellow jr d.data ) | ||
else | ||
info d.$key | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "parse html to list (onepiece)" ] = ( T, done ) -> | ||
SP = require '../..' | ||
T.eq ( type_of SP.HTML.new_onepiece_parser ), 'function' | ||
parse = SP.HTML.new_onepiece_parser() | ||
#......................................................................................................... | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
html = probe | ||
result = parse html | ||
* show html, result | ||
resolve result | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
*/ | ||
//----------------------------------------------------------------------------------------------------------- | ||
@@ -955,0 +1015,0 @@ this["HTML.html_as_datoms (dubious)"] = async function(T, done) { |
{ | ||
"name": "intertext", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "Services for Recurrent Text-related Tasks", | ||
@@ -37,3 +37,3 @@ "main": "lib/main.js", | ||
"multimix": "^2.1.3", | ||
"steampipes": "^4.1.1" | ||
"steampipes": "^5.0.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "devDependencies": { |
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
206835
2835
+ Addedsteampipes@5.3.0(transitive)
+ Addedtimsort@0.3.0(transitive)
- Removedatlas-html-stream@1.2.0(transitive)
- Removedatlas-seq-matcher@1.0.2(transitive)
- Removedsteampipes@4.1.1(transitive)
Updatedsteampipes@^5.0.0