Intial Commit
This commit is contained in:
15
nodered/rootfs/data/node_modules/html-to-text/.codeclimate.yml
generated
vendored
Normal file
15
nodered/rootfs/data/node_modules/html-to-text/.codeclimate.yml
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
engines:
|
||||
duplication:
|
||||
enabled: true
|
||||
config:
|
||||
languages:
|
||||
- javascript
|
||||
eslint-4:
|
||||
enabled: true
|
||||
fixme:
|
||||
enabled: true
|
||||
ratings:
|
||||
paths:
|
||||
- "**.js"
|
||||
exclude_paths:
|
||||
- test/
|
||||
3
nodered/rootfs/data/node_modules/html-to-text/.eslintignore
generated
vendored
Normal file
3
nodered/rootfs/data/node_modules/html-to-text/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
**/*{.,-}min.js
|
||||
node_modules
|
||||
coverage
|
||||
209
nodered/rootfs/data/node_modules/html-to-text/.eslintrc.yml
generated
vendored
Normal file
209
nodered/rootfs/data/node_modules/html-to-text/.eslintrc.yml
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
env:
|
||||
amd: false
|
||||
browser: false
|
||||
es6: false
|
||||
jquery: false
|
||||
node: true
|
||||
jasmine: true
|
||||
|
||||
# http://eslint.org/docs/rules/
|
||||
rules:
|
||||
# Possible Errors
|
||||
comma-dangle: [2, never]
|
||||
no-cond-assign: 2
|
||||
no-console: 0
|
||||
no-constant-condition: 2
|
||||
no-control-regex: 2
|
||||
no-debugger: 2
|
||||
no-dupe-args: 2
|
||||
no-dupe-keys: 2
|
||||
no-duplicate-case: 2
|
||||
no-empty: 2
|
||||
no-empty-character-class: 2
|
||||
no-ex-assign: 2
|
||||
no-extra-boolean-cast: 2
|
||||
no-extra-parens: 0
|
||||
no-extra-semi: 2
|
||||
no-func-assign: 2
|
||||
no-inner-declarations: [2, functions]
|
||||
no-invalid-regexp: 2
|
||||
no-irregular-whitespace: 2
|
||||
no-negated-in-lhs: 2
|
||||
no-obj-calls: 2
|
||||
no-regex-spaces: 2
|
||||
no-sparse-arrays: 2
|
||||
no-unexpected-multiline: 2
|
||||
no-unreachable: 2
|
||||
use-isnan: 2
|
||||
valid-jsdoc: 0
|
||||
valid-typeof: 2
|
||||
|
||||
# Best Practices
|
||||
accessor-pairs: 2
|
||||
block-scoped-var: 0
|
||||
complexity: 0
|
||||
consistent-return: 0
|
||||
curly: 0
|
||||
default-case: 0
|
||||
dot-location: 0
|
||||
dot-notation: 0
|
||||
eqeqeq: 2
|
||||
guard-for-in: 2
|
||||
no-alert: 2
|
||||
no-caller: 2
|
||||
no-case-declarations: 2
|
||||
no-div-regex: 2
|
||||
no-else-return: 0
|
||||
no-empty-pattern: 2
|
||||
no-eq-null: 2
|
||||
no-eval: 2
|
||||
no-extend-native: 2
|
||||
no-extra-bind: 2
|
||||
no-fallthrough: 2
|
||||
no-floating-decimal: 0
|
||||
no-implicit-coercion: 0
|
||||
no-implied-eval: 2
|
||||
no-invalid-this: 0
|
||||
no-iterator: 2
|
||||
no-labels: 0
|
||||
no-lone-blocks: 2
|
||||
no-loop-func: 2
|
||||
no-magic-number: 0
|
||||
no-multi-spaces: 0
|
||||
no-multi-str: 0
|
||||
no-native-reassign: 2
|
||||
no-new-func: 2
|
||||
no-new-wrappers: 2
|
||||
no-new: 2
|
||||
no-octal-escape: 2
|
||||
no-octal: 2
|
||||
no-proto: 2
|
||||
no-redeclare: 2
|
||||
no-return-assign: 2
|
||||
no-script-url: 2
|
||||
no-self-compare: 2
|
||||
no-sequences: 0
|
||||
no-throw-literal: 0
|
||||
no-unused-expressions: 2
|
||||
no-useless-call: 2
|
||||
no-useless-concat: 2
|
||||
no-void: 2
|
||||
no-warning-comments: 0
|
||||
no-with: 2
|
||||
radix: 2
|
||||
vars-on-top: 0
|
||||
wrap-iife: 2
|
||||
yoda: 0
|
||||
|
||||
# Strict
|
||||
strict: 0
|
||||
|
||||
# Variables
|
||||
init-declarations: 0
|
||||
no-catch-shadow: 2
|
||||
no-delete-var: 2
|
||||
no-label-var: 2
|
||||
no-shadow-restricted-names: 2
|
||||
no-shadow: 0
|
||||
no-undef-init: 2
|
||||
no-undef: 2
|
||||
no-undefined: 0
|
||||
no-unused-vars: 0
|
||||
no-use-before-define: 0
|
||||
|
||||
# Node.js and CommonJS
|
||||
callback-return: 2
|
||||
global-require: 2
|
||||
handle-callback-err: 2
|
||||
no-mixed-requires: 0
|
||||
no-new-require: 0
|
||||
no-path-concat: 2
|
||||
no-process-exit: 2
|
||||
no-restricted-modules: 0
|
||||
no-sync: 0
|
||||
|
||||
# Stylistic Issues
|
||||
array-bracket-spacing: 0
|
||||
block-spacing: 0
|
||||
brace-style: 0
|
||||
camelcase: 0
|
||||
comma-spacing: 0
|
||||
comma-style: 0
|
||||
computed-property-spacing: 0
|
||||
consistent-this: 0
|
||||
eol-last: 0
|
||||
func-names: 0
|
||||
func-style: 0
|
||||
id-length: 0
|
||||
id-match: 0
|
||||
indent-legacy: [2, 2, { "SwitchCase": 1 }]
|
||||
jsx-quotes: 0
|
||||
key-spacing: 0
|
||||
linebreak-style: 0
|
||||
lines-around-comment: 0
|
||||
max-depth: 0
|
||||
max-len: [2, 130]
|
||||
max-nested-callbacks: 0
|
||||
max-params: 0
|
||||
max-statements: [2, 30]
|
||||
new-cap: 0
|
||||
new-parens: 0
|
||||
newline-after-var: 0
|
||||
no-array-constructor: 0
|
||||
no-bitwise: 0
|
||||
no-continue: 0
|
||||
no-inline-comments: 0
|
||||
no-lonely-if: 0
|
||||
no-mixed-spaces-and-tabs: 0
|
||||
no-multiple-empty-lines: 0
|
||||
no-negated-condition: 0
|
||||
no-nested-ternary: 0
|
||||
no-new-object: 0
|
||||
no-plusplus: 0
|
||||
no-restricted-syntax: 0
|
||||
no-spaced-func: 0
|
||||
no-ternary: 0
|
||||
no-trailing-spaces: 0
|
||||
no-underscore-dangle: 0
|
||||
no-unneeded-ternary: 0
|
||||
object-curly-spacing: 0
|
||||
one-var: 0
|
||||
operator-assignment: 0
|
||||
operator-linebreak: 0
|
||||
padded-blocks: 0
|
||||
quote-props: 0
|
||||
quotes: 0
|
||||
require-jsdoc: 0
|
||||
semi-spacing: 0
|
||||
semi: [error, always]
|
||||
sort-vars: 0
|
||||
space-after-keywords: 0
|
||||
space-before-blocks: 0
|
||||
space-before-function-paren: 0
|
||||
space-before-keywords: 0
|
||||
space-in-parens: 0
|
||||
space-infix-ops: 0
|
||||
space-return-throw-case: 0
|
||||
space-unary-ops: 0
|
||||
spaced-comment: 0
|
||||
wrap-regex: 0
|
||||
|
||||
# ECMAScript 6
|
||||
arrow-body-style: 0
|
||||
arrow-parens: 0
|
||||
arrow-spacing: 0
|
||||
constructor-super: 0
|
||||
generator-star-spacing: 0
|
||||
no-arrow-condition: 0
|
||||
no-class-assign: 0
|
||||
no-const-assign: 0
|
||||
no-dupe-class-members: 0
|
||||
no-this-before-super: 0
|
||||
no-var: 0
|
||||
object-shorthand: 0
|
||||
prefer-arrow-callback: 0
|
||||
prefer-const: 0
|
||||
prefer-reflect: 0
|
||||
prefer-spread: 0
|
||||
prefer-template: 0
|
||||
require-yield: 0
|
||||
14
nodered/rootfs/data/node_modules/html-to-text/.travis.yml
generated
vendored
Normal file
14
nodered/rootfs/data/node_modules/html-to-text/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token:
|
||||
secure: IbQv9JBOVRXApd+Hd/WQ47f6Ty+2i1ly6hzFXLTuMt7cM/72KC4ocwHsuP6OdiTAgRuSwCHar92v2uTgx0vTjLCBLBCmWYjhVq1u1Pr+9oBidQCT7ryHATNDEh1V68bkmsSXzRDh7j5sesBz7mwzFIpF7FGUlZm3Glba6HbKP5E=
|
||||
|
||||
after_success:
|
||||
- npm install -g codeclimate-test-reporter
|
||||
- codeclimate-test-reporter < coverage/lcov.info
|
||||
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
||||
122
nodered/rootfs/data/node_modules/html-to-text/CHANGELOG.md
generated
vendored
Normal file
122
nodered/rootfs/data/node_modules/html-to-text/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
# Changelog
|
||||
|
||||
## Version 5.1.1
|
||||
|
||||
* `preserveNewLines` whitespace issue fixed [#162](https://github.com/werk85/node-html-to-text/pull/162)
|
||||
|
||||
## Version 5.1.0
|
||||
|
||||
* Hard-coded CLI options removed [#173](https://github.com/werk85/node-html-to-text/pull/173)
|
||||
|
||||
## Version 5.0.0
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
#### fromFile removed
|
||||
|
||||
The function `fromFile` is removed. It was the main reason `html-to-text` could not be used in the browser [#164](https://github.com/werk85/node-html-to-text/pull/164).
|
||||
|
||||
You can get the `fromFile` functionality back by using the following code
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const { fromString } = require('html-to-text');
|
||||
|
||||
// Callback version
|
||||
const fromFile = (file, options, callback) => {
|
||||
if (!callback) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
fs.readFile(file, 'utf8', (err, str) => {
|
||||
if (err) return callback(err);
|
||||
callback(null, fromString(str, options));
|
||||
});
|
||||
};
|
||||
|
||||
// Promise version
|
||||
const fromFile = (file, option) => fs.promises.readFile(file, 'utf8').then(html => fromString(html, options));
|
||||
|
||||
// Sync version
|
||||
const fromFileSync = (file, options) => fromString(fs.readFileSync(file, 'utf8'), options);
|
||||
```
|
||||
|
||||
#### Supported NodeJS Versions
|
||||
Node versions < 6 are no longer supported.
|
||||
|
||||
|
||||
## Version 4.0.0
|
||||
|
||||
* Support dropped for node version < 4.
|
||||
* New option `unorderedListItemPrefix` added.
|
||||
* HTML entities in links are not supported.
|
||||
|
||||
## Version 3.3.0
|
||||
|
||||
* Ability to pass custom formatting via the `format` option #128
|
||||
* Enhanced support for alpha ordered list types added #123
|
||||
|
||||
## Version 3.2.0
|
||||
|
||||
* Basic support for alpha ordered list types added #122
|
||||
* This includes support for the `ol` type values `1`, `a` and `A`
|
||||
|
||||
## Version 3.1.0
|
||||
|
||||
* Support for the ordered list start attribute added #117
|
||||
* Option to format paragraph with single new line #112
|
||||
* `noLinksBrackets` options added #119
|
||||
|
||||
## Version 3.0.0
|
||||
|
||||
* Switched from `htmlparser` to `htmlparser2` #113
|
||||
* Treat non-numeric colspans as zero and handle them gracefully #105
|
||||
|
||||
## Version 2.1.1
|
||||
|
||||
* Extra space ploblem fixed. #88
|
||||
|
||||
## Version 2.1.0
|
||||
|
||||
* New option to disable `uppercaseHeadings` added. #86
|
||||
* Starting point of html to text conversion can now be defined in the options via the `baseElement` option. #83
|
||||
* Support for long words added. The behaviour can be configured via the `longWordSplit` option. #83
|
||||
|
||||
## Version 2.0.0
|
||||
|
||||
* Unicode support added. #81
|
||||
* New option `decodeOptions` added.
|
||||
* Dependencies updated.
|
||||
|
||||
Breaking Changes:
|
||||
|
||||
* Minimum node version increased to >=0.10.0
|
||||
|
||||
## Version 1.6.2
|
||||
|
||||
* Fixed: correctly handle HTML entities for images #82
|
||||
|
||||
## Version 1.6.1
|
||||
|
||||
* Fixed: using --tables=true doesn't produce the expected results. #80
|
||||
|
||||
## Version 1.6.0
|
||||
|
||||
* Preserve newlines in text feature added #75
|
||||
|
||||
## Version 1.5.1
|
||||
|
||||
* Support for h5 and h6 tags added #74
|
||||
|
||||
## Version 1.5.0
|
||||
|
||||
* Entity regex is now less greedy #69 #70
|
||||
|
||||
## Version 1.4.0
|
||||
|
||||
* Uppercase tag processing added. Table center support added. #56
|
||||
* Unuused dependencies removed.
|
||||
|
||||
## Version 1.3.2
|
||||
|
||||
* Support Node 4 engine #64
|
||||
24
nodered/rootfs/data/node_modules/html-to-text/LICENSE-MIT
generated
vendored
Normal file
24
nodered/rootfs/data/node_modules/html-to-text/LICENSE-MIT
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2014 werk85 http://werk85.de
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
319
nodered/rootfs/data/node_modules/html-to-text/README.md
generated
vendored
Normal file
319
nodered/rootfs/data/node_modules/html-to-text/README.md
generated
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
# html-to-text
|
||||
|
||||
[](https://travis-ci.org/werk85/node-html-to-text)
|
||||
[](https://codeclimate.com/github/werk85/node-html-to-text/coverage)
|
||||
|
||||
An advanced converter that parses HTML and returns beautiful text. It was mainly designed to transform HTML E-Mail templates to a text representation. So it is currently optimized for table layouts.
|
||||
|
||||
### Features:
|
||||
|
||||
* Transform headlines to uppercase text.
|
||||
* Convert tables to an appropiate text representation with rows and columns.
|
||||
* Word wrapping for paragraphs (default 80 chars).
|
||||
* Automatic extraction of href information from links.
|
||||
* `<br>` conversion to `\n`.
|
||||
* Unicode support.
|
||||
* Runs in browser and server environments.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install html-to-text
|
||||
```
|
||||
|
||||
Or when you want to use it as command line interface it is recommended to install it globally via
|
||||
|
||||
```
|
||||
npm install html-to-text -g
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const htmlToText = require('html-to-text');
|
||||
|
||||
const text = htmlToText.fromString('<h1>Hello World</h1>', {
|
||||
wordwrap: 130
|
||||
});
|
||||
console.log(text); // Hello World
|
||||
```
|
||||
|
||||
### Options:
|
||||
|
||||
You can configure the behaviour of html-to-text with the following options:
|
||||
|
||||
* `tables` allows to select certain tables by the `class` or `id` attribute from the HTML document. This is necessary because the majority of HTML E-Mails uses a table based layout. Prefix your table selectors with an `.` for the `class` and with a `#` for the `id` attribute. All other tables are ignored. You can assign `true` to this attribute to select all tables. Default: `[]`
|
||||
* `wordwrap` defines after how many chars a line break should follow in `p` elements. Set to `null` or `false` to disable word-wrapping. Default: `80`
|
||||
* `linkHrefBaseUrl` allows you to specify the server host for href attributes, where the links start at the root (`/`). For example, `linkHrefBaseUrl = 'http://asdf.com'` and `<a href='/dir/subdir'>...</a>` the link in the text will be `http://asdf.com/dir/subdir`. Keep in mind that `linkHrefBaseUrl` shouldn't end with a `/`.
|
||||
* `hideLinkHrefIfSameAsText` by default links are translated the following `<a href='link'>text</a>` => becomes => `text [link]`. If this option is set to true and `link` and `text` are the same, `[link]` will be hidden and only `text` visible.
|
||||
* `noLinkBrackets` dont print brackets around the link if `true`.
|
||||
* `ignoreHref` ignore all document links if `true`.
|
||||
* `ignoreImage` ignore all document images if `true`.
|
||||
* `preserveNewlines` by default, any newlines `\n` in a block of text will be removed. If `true`, these newlines will not be removed.
|
||||
* `decodeOptions` defines the text decoding options given to `he.decode`. For more informations see the [he](https://github.com/mathiasbynens/he) module.
|
||||
* `uppercaseHeadings` by default, headings (`<h1>`, `<h2>`, etc) are uppercased. Set to `false` to leave headings as they are.
|
||||
* `singleNewLineParagraphs` by default, paragraphs are converted with two newlines (`\n\n`). Set to `true` to convert to a single newline.
|
||||
* `baseElement` defines the tags whose text content will be captured from the html. All content will be captured below the baseElement tags and added to the resulting text output. This option allows the user to specify an array of elements as base elements using a single tag with css class and id parameters e.g. [`p.class1.class2#id1#id2`, `p.class1.class2#id1#id2`] . Default: `body`
|
||||
* `returnDomByDefault` convert the entire document if we don't find the tag we're looking for if `true`.
|
||||
* `longWordSplit` describes how to wrap long words, has the following parameters:
|
||||
* `wrapCharacters` is an array containing the characters that may be wrapped on, these are used in order
|
||||
* `forceWrapOnLimit` defines whether to break long words on the limit if `true`.
|
||||
* `format` pass an object to enable custom formatting for specific elements (see below)
|
||||
* `unorderedListItemPrefix` defines the string that is used as item prefix for unordered lists `<ol>`. Default: `' * '`
|
||||
|
||||
### Override formatting for specific elements
|
||||
|
||||
By using the `format` option, you can specify formatting for these elements: `text`, `image`, `lineBreak`, `paragraph`, `anchor`, `heading`, `table`, `orderedList`, `unorderedList`, `listItem`, `horizontalLine`.
|
||||
|
||||
Each key must be a function which eventually receive `elem` (the current elem), `fn` (the next formatting function) and `options` (the options passed to html-to-text).
|
||||
|
||||
```js
|
||||
var htmlToText = require('html-to-text');
|
||||
|
||||
var text = htmlToText.fromString('<h1>Hello World</h1>', {
|
||||
format: {
|
||||
heading: function (elem, fn, options) {
|
||||
var h = fn(elem.children, options);
|
||||
return '====\n' + h.toUpperCase() + '\n====';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log(text);
|
||||
```
|
||||
|
||||
## Command Line Interface
|
||||
|
||||
It is possible to use html-to-text as command line interface. This allows an easy validation of your generated text and the integration in other systems that does not run on node.js.
|
||||
|
||||
`html-to-text` uses `stdin` and `stdout` for data in and output. So you can use `html-to-text` the following way:
|
||||
|
||||
```
|
||||
cat example/test.html | html-to-text > test.txt
|
||||
```
|
||||
|
||||
There also all options available as described above. You can use them like this:
|
||||
|
||||
```
|
||||
cat example/test.html | html-to-text --tables=#invoice,.address --wordwrap=100 > test.txt
|
||||
```
|
||||
|
||||
The `tables` option has to be declared as comma separated list without whitespaces.
|
||||
|
||||
## Example
|
||||
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h2>Paragraphs</h2>
|
||||
<p class="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <a href="www.github.com">Github</a>
|
||||
</p>
|
||||
<p class="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
</p>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Pretty printed table</h2>
|
||||
<table id="invoice">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Article</th>
|
||||
<th>Price</th>
|
||||
<th>Taxes</th>
|
||||
<th>Amount</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Product 1<br />
|
||||
<span style="font-size:0.8em">Contains: 1x Product 1</span>
|
||||
</p>
|
||||
</td>
|
||||
<td align="right" valign="top">6,99€</td>
|
||||
<td align="right" valign="top">7%</td>
|
||||
<td align="right" valign="top">1</td>
|
||||
<td align="right" valign="top">6,99€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Shipment costs</td>
|
||||
<td align="right">3,25€</td>
|
||||
<td align="right">7%</td>
|
||||
<td align="right">1</td>
|
||||
<td align="right">3,25€</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td colspan="3">to pay: 10,24€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3">Taxes 7%: 0,72€</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Lists</h2>
|
||||
<ul>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
</ul>
|
||||
<ol>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr />
|
||||
<h2>Column Layout with tables</h2>
|
||||
<table class="address">
|
||||
<tr>
|
||||
<th align="left">Invoice Address</th>
|
||||
<th align="left">Shipment Address</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
<p>
|
||||
Mr.<br/>
|
||||
John Doe<br/>
|
||||
Featherstone Street 49<br/>
|
||||
28199 Bremen<br/>
|
||||
</p>
|
||||
</td>
|
||||
<td align="left">
|
||||
<p>
|
||||
Mr.<br/>
|
||||
John Doe<br/>
|
||||
Featherstone Street 49<br/>
|
||||
28199 Bremen<br/>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Mailto formating</h2>
|
||||
<p class="normal-space small">
|
||||
Some Company<br />
|
||||
Some Street 42<br />
|
||||
Somewhere<br />
|
||||
E-Mail: <a href="mailto:test@example.com">Click here</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Gets converted to:
|
||||
|
||||
```
|
||||
PARAGRAPHS
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
|
||||
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
||||
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
|
||||
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
||||
takimata sanctus est Lorem ipsum dolor sit amet. Github [www.github.com]
|
||||
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
|
||||
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
||||
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
|
||||
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
||||
takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
PRETTY PRINTED TABLE
|
||||
ARTICLE PRICE TAXES AMOUNT TOTAL
|
||||
Product 1 6,99€ 7% 1 6,99€
|
||||
Contains: 1x Product 1
|
||||
Shipment costs 3,25€ 7% 1 3,25€
|
||||
to pay: 10,24€
|
||||
Taxes 7%: 0,72€
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
LISTS
|
||||
* At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
* At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
1. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
2. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
COLUMN LAYOUT WITH TABLES
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
MAILTO FORMATING
|
||||
Some Company
|
||||
Some Street 42
|
||||
Somewhere
|
||||
E-Mail: Click here [test@example.com]
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2019 werk85 <malte@werk85.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
46
nodered/rootfs/data/node_modules/html-to-text/bin/cli.js
generated
vendored
Executable file
46
nodered/rootfs/data/node_modules/html-to-text/bin/cli.js
generated
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env node
|
||||
var parseArgs = require('minimist');
|
||||
|
||||
var htmlToText = require('../lib/html-to-text');
|
||||
|
||||
var argv = parseArgs(process.argv.slice(2), {
|
||||
string: [
|
||||
'tables'
|
||||
],
|
||||
boolean: [
|
||||
'noLinkBrackets',
|
||||
'ignoreHref',
|
||||
'ignoreImage'
|
||||
],
|
||||
alias: {
|
||||
'ignore-href': 'ignoreHref',
|
||||
'ignore-image': 'ignoreImage'
|
||||
},
|
||||
default: {
|
||||
'wordwrap': 80
|
||||
}
|
||||
});
|
||||
|
||||
argv.tables = interpretTables(argv.tables);
|
||||
|
||||
var text = '';
|
||||
|
||||
process.title = 'html-to-text';
|
||||
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin.on('data', function data(data) {
|
||||
text += data;
|
||||
});
|
||||
|
||||
process.stdin.on('end', function end() {
|
||||
text = htmlToText.fromString(text, argv);
|
||||
process.stdout.write(text + '\n', 'utf-8');
|
||||
});
|
||||
|
||||
function interpretTables(tables) {
|
||||
if (!tables || tables === '' || tables === 'false') {
|
||||
return [];
|
||||
}
|
||||
return tables === 'true' || tables.split(',');
|
||||
}
|
||||
18
nodered/rootfs/data/node_modules/html-to-text/example/html-to-text.js
generated
vendored
Normal file
18
nodered/rootfs/data/node_modules/html-to-text/example/html-to-text.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
var path = require('path');
|
||||
|
||||
var htmlToText = require('../lib/html-to-text');
|
||||
|
||||
console.log('fromString:');
|
||||
var text = htmlToText.fromString('<h1>Hello World</h1>', {
|
||||
wordwrap: 130
|
||||
});
|
||||
console.log(text);
|
||||
console.log();
|
||||
|
||||
console.log('fromFile:');
|
||||
htmlToText.fromFile(path.join(__dirname, 'test.html'), {
|
||||
tables: ['#invoice', '.address']
|
||||
}, function(err, text) {
|
||||
if (err) return console.error(err);
|
||||
console.log(text);
|
||||
});
|
||||
146
nodered/rootfs/data/node_modules/html-to-text/example/test.html
generated
vendored
Normal file
146
nodered/rootfs/data/node_modules/html-to-text/example/test.html
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
h2 {
|
||||
font-size:18px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
alert('Hallo Welt');
|
||||
</script>
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h2>Paragraphs</h2>
|
||||
<p class="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <a href="www.github.com">Github</a>
|
||||
</p>
|
||||
<p class="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
</p>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Pretty printed table</h2>
|
||||
<table id="invoice">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Article</th>
|
||||
<th>Price</th>
|
||||
<th>Taxes</th>
|
||||
<th>Amount</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Product 1<br />
|
||||
<span style="font-size:0.8em">Contains: 1x Product 1</span>
|
||||
</p>
|
||||
</td>
|
||||
<td align="right" valign="top">6,99€</td>
|
||||
<td align="right" valign="top">7%</td>
|
||||
<td align="right" valign="top">1</td>
|
||||
<td align="right" valign="top">6,99€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Shipment costs</td>
|
||||
<td align="right">3,25€</td>
|
||||
<td align="right">7%</td>
|
||||
<td align="right">1</td>
|
||||
<td align="right">3,25€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td colspan="3">to pay: 10,24€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3">Taxes 7%: 0,72€</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Lists</h2>
|
||||
<ul>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
</ul>
|
||||
<ol>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr />
|
||||
<h2>Column Layout with tables</h2>
|
||||
<table class="address">
|
||||
<tr>
|
||||
<th align="left">Invoice Address</th>
|
||||
<th align="left">Shipment Address</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
<p>
|
||||
Mr.<br/>
|
||||
John Doe<br/>
|
||||
Featherstone Street 49<br/>
|
||||
28199 Bremen<br/>
|
||||
</p>
|
||||
</td>
|
||||
<td align="left">
|
||||
<p>
|
||||
Mr.<br/>
|
||||
John Doe<br/>
|
||||
Featherstone Street 49<br/>
|
||||
28199 Bremen<br/>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="#anchor"></a>
|
||||
<hr/>
|
||||
<h2>Mailto formating</h2>
|
||||
<p class="normal-space small">
|
||||
Some Company<br />
|
||||
Some Street 42<br />
|
||||
Somewhere<br />
|
||||
E-Mail: <a href="mailto:test@example.com">Click here</a>!
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
<h2>Pretty printed Source Code</h2>
|
||||
<pre>
|
||||
htmlToText.fromFile(path.join(__dirname, 'test.html'), {
|
||||
tables: ['#invoice', '.address']
|
||||
}, function(err, text) {
|
||||
if (err) return console.error(err);
|
||||
console.log(text);
|
||||
});
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
1
nodered/rootfs/data/node_modules/html-to-text/index.js
generated
vendored
Normal file
1
nodered/rootfs/data/node_modules/html-to-text/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/html-to-text');
|
||||
268
nodered/rootfs/data/node_modules/html-to-text/lib/formatter.js
generated
vendored
Normal file
268
nodered/rootfs/data/node_modules/html-to-text/lib/formatter.js
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
var max = require('lodash/max');
|
||||
var compact = require('lodash/compact');
|
||||
var times = require('lodash/times');
|
||||
|
||||
var trimStart = require('lodash/trimStart');
|
||||
var padEnd = require('lodash/padEnd');
|
||||
|
||||
var he = require('he');
|
||||
|
||||
var helper = require('./helper');
|
||||
|
||||
function formatText(elem, options) {
|
||||
var text = elem.data || "";
|
||||
text = he.decode(text, options.decodeOptions);
|
||||
|
||||
if (options.isInPre) {
|
||||
return text;
|
||||
} else {
|
||||
return helper.wordwrap(elem.trimLeadingSpace ? trimStart(text) : text, options);
|
||||
}
|
||||
}
|
||||
|
||||
function formatImage(elem, options) {
|
||||
if (options.ignoreImage) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var result = '', attribs = elem.attribs || {};
|
||||
if (attribs.alt) {
|
||||
result += he.decode(attribs.alt, options.decodeOptions);
|
||||
if (attribs.src) {
|
||||
result += ' ';
|
||||
}
|
||||
}
|
||||
if (attribs.src) {
|
||||
result += '[' + attribs.src + ']';
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
function formatLineBreak(elem, fn, options) {
|
||||
return '\n' + fn(elem.children, options);
|
||||
}
|
||||
|
||||
function formatParagraph(elem, fn, options) {
|
||||
var paragraph = fn(elem.children, options);
|
||||
if (options.singleNewLineParagraphs) {
|
||||
return paragraph + '\n';
|
||||
} else {
|
||||
return paragraph + '\n\n';
|
||||
}
|
||||
}
|
||||
|
||||
function formatHeading(elem, fn, options) {
|
||||
var heading = fn(elem.children, options);
|
||||
if (options.uppercaseHeadings) {
|
||||
heading = heading.toUpperCase();
|
||||
}
|
||||
return heading + '\n';
|
||||
}
|
||||
|
||||
// If we have both href and anchor text, format it in a useful manner:
|
||||
// - "anchor text [href]"
|
||||
// Otherwise if we have only anchor text or an href, we return the part we have:
|
||||
// - "anchor text" or
|
||||
// - "href"
|
||||
function formatAnchor(elem, fn, options) {
|
||||
var href = '';
|
||||
// Always get the anchor text
|
||||
var storedCharCount = options.lineCharCount;
|
||||
var text = fn(elem.children || [], options);
|
||||
if (!text) {
|
||||
text = '';
|
||||
}
|
||||
|
||||
var result = elem.trimLeadingSpace ? trimStart(text) : text;
|
||||
|
||||
if (!options.ignoreHref) {
|
||||
// Get the href, if present
|
||||
if (elem.attribs && elem.attribs.href) {
|
||||
href = elem.attribs.href.replace(/^mailto:/, '');
|
||||
}
|
||||
if (href) {
|
||||
if ((!options.noAnchorUrl) || (options.noAnchorUrl && href[0] !== '#')) {
|
||||
if (options.linkHrefBaseUrl && href.indexOf('/') === 0) {
|
||||
href = options.linkHrefBaseUrl + href;
|
||||
}
|
||||
if (!options.hideLinkHrefIfSameAsText || href !== helper.replaceAll(result, '\n', '')) {
|
||||
if (!options.noLinkBrackets) {
|
||||
result += ' [' + href + ']';
|
||||
} else {
|
||||
result += ' ' + href;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
options.lineCharCount = storedCharCount;
|
||||
|
||||
return formatText({ data: result || href, trimLeadingSpace: elem.trimLeadingSpace }, options);
|
||||
}
|
||||
|
||||
function formatHorizontalLine(elem, fn, options) {
|
||||
return '\n' + '-'.repeat(options.wordwrap) + '\n\n';
|
||||
}
|
||||
|
||||
function formatListItem(prefix, elem, fn, options) {
|
||||
options = Object.assign({}, options);
|
||||
// Reduce the wordwrap for sub elements.
|
||||
if (options.wordwrap) {
|
||||
options.wordwrap -= prefix.length;
|
||||
}
|
||||
// Process sub elements.
|
||||
var text = fn(elem.children, options);
|
||||
// Replace all line breaks with line break + prefix spacing.
|
||||
text = text.replace(/\n/g, '\n' + ' '.repeat(prefix.length));
|
||||
// Add first prefix and line break at the end.
|
||||
return prefix + text + '\n';
|
||||
}
|
||||
|
||||
var whiteSpaceRegex = /^\s*$/;
|
||||
|
||||
function formatUnorderedList(elem, fn, options) {
|
||||
var result = '';
|
||||
var prefix = options.unorderedListItemPrefix;
|
||||
var nonWhiteSpaceChildren = (elem.children || []).filter(function(child) {
|
||||
return child.type !== 'text' || !whiteSpaceRegex.test(child.data);
|
||||
});
|
||||
nonWhiteSpaceChildren.forEach(function(elem) {
|
||||
result += formatListItem(prefix, elem, fn, options);
|
||||
});
|
||||
return result + '\n';
|
||||
}
|
||||
|
||||
function formatOrderedList(elem, fn, options) {
|
||||
var result = '';
|
||||
var nonWhiteSpaceChildren = (elem.children || []).filter(function(child) {
|
||||
return child.type !== 'text' || !whiteSpaceRegex.test(child.data);
|
||||
});
|
||||
// Return different functions for different OL types
|
||||
var typeFunction = (function() {
|
||||
// Determine type
|
||||
var olType = elem.attribs.type || '1';
|
||||
// TODO Imeplement the other valid types
|
||||
// Fallback to type '1' function for other valid types
|
||||
switch(olType) {
|
||||
case 'a': return function(start, i) { return String.fromCharCode(i + start + 97);};
|
||||
case 'A': return function(start, i) { return String.fromCharCode(i + start + 65);};
|
||||
case '1':
|
||||
default: return function(start, i) { return i + 1 + start;};
|
||||
}
|
||||
}());
|
||||
// Make sure there are list items present
|
||||
if (nonWhiteSpaceChildren.length) {
|
||||
// Calculate initial start from ol attribute
|
||||
var start = Number(elem.attribs.start || '1') - 1;
|
||||
// Calculate the maximum length to i.
|
||||
var maxLength = (nonWhiteSpaceChildren.length + start).toString().length;
|
||||
nonWhiteSpaceChildren.forEach(function(elem, i) {
|
||||
// Use different function depending on type
|
||||
var index = typeFunction(start, i);
|
||||
// Calculate the needed spacing for nice indentation.
|
||||
var spacing = maxLength - index.toString().length;
|
||||
var prefix = ' ' + index + '. ' + ' '.repeat(spacing);
|
||||
result += formatListItem(prefix, elem, fn, options);
|
||||
});
|
||||
}
|
||||
return result + '\n';
|
||||
}
|
||||
|
||||
function tableToString(table) {
|
||||
// Determine space width per column
|
||||
// Convert all rows to lengths
|
||||
var widths = table.map(function(row) {
|
||||
return row.map(function(col) {
|
||||
return col.length;
|
||||
});
|
||||
});
|
||||
// Invert rows with colums
|
||||
widths = helper.arrayZip(widths);
|
||||
// Determine the max values for each column
|
||||
widths = widths.map(function(col) {
|
||||
return max(col);
|
||||
});
|
||||
|
||||
// Build the table
|
||||
var text = '';
|
||||
table.forEach(function(row) {
|
||||
var i = 0;
|
||||
row.forEach(function(col) {
|
||||
text += padEnd(col.trim(), widths[i++], ' ') + ' ';
|
||||
});
|
||||
text += '\n';
|
||||
});
|
||||
return text + '\n';
|
||||
}
|
||||
|
||||
function formatTable(elem, fn, options) {
|
||||
var table = [];
|
||||
elem.children.forEach(tryParseRows);
|
||||
return tableToString(table);
|
||||
|
||||
function tryParseRows(elem) {
|
||||
if (elem.type !== 'tag') {
|
||||
return;
|
||||
}
|
||||
switch (elem.name.toLowerCase()) {
|
||||
case "thead":
|
||||
case "tbody":
|
||||
case "tfoot":
|
||||
case "center":
|
||||
elem.children.forEach(tryParseRows);
|
||||
return;
|
||||
|
||||
case 'tr':
|
||||
var rows = [];
|
||||
elem.children.forEach(function(elem) {
|
||||
var tokens, count;
|
||||
if (elem.type === 'tag') {
|
||||
switch (elem.name.toLowerCase()) {
|
||||
case 'th':
|
||||
tokens = formatHeading(elem, fn, options).split('\n');
|
||||
rows.push(compact(tokens));
|
||||
break;
|
||||
|
||||
case 'td':
|
||||
tokens = fn(elem.children, options).split('\n');
|
||||
rows.push(compact(tokens));
|
||||
// Fill colspans with empty values
|
||||
if (elem.attribs && elem.attribs.colspan) {
|
||||
count = elem.attribs.colspan - 1 || 0;
|
||||
times(count, function() {
|
||||
rows.push(['']);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
rows = helper.arrayZip(rows);
|
||||
rows.forEach(function(row) {
|
||||
row = row.map(function(col) {
|
||||
return col || '';
|
||||
});
|
||||
table.push(row);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function formatBlockquote(elem, fn, options) {
|
||||
return '> ' + fn(elem.children, options) + '\n';
|
||||
}
|
||||
|
||||
exports.text = formatText;
|
||||
exports.image = formatImage;
|
||||
exports.lineBreak = formatLineBreak;
|
||||
exports.paragraph = formatParagraph;
|
||||
exports.anchor = formatAnchor;
|
||||
exports.heading = formatHeading;
|
||||
exports.table = formatTable;
|
||||
exports.orderedList = formatOrderedList;
|
||||
exports.unorderedList = formatUnorderedList;
|
||||
exports.listItem = formatListItem;
|
||||
exports.horizontalLine = formatHorizontalLine;
|
||||
exports.blockquote = formatBlockquote;
|
||||
139
nodered/rootfs/data/node_modules/html-to-text/lib/helper.js
generated
vendored
Normal file
139
nodered/rootfs/data/node_modules/html-to-text/lib/helper.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
var zip = require('lodash/zip');
|
||||
var trimEnd = require('lodash/trimEnd');
|
||||
|
||||
// Split a long word up to fit within the word wrap limit. Use either a
|
||||
// character to split looking back from the word wrap limit, or
|
||||
// truncate to the word wrap limit.
|
||||
function splitLongWord(word, options) {
|
||||
var wrapCharacters = options.longWordSplit.wrapCharacters || [];
|
||||
var forceWrapOnLimit = options.longWordSplit.forceWrapOnLimit || false;
|
||||
var max = options.wordwrap;
|
||||
|
||||
var fuseWord = [];
|
||||
var idx = 0;
|
||||
while (word.length > max) {
|
||||
var firstLine = word.substr(0, max);
|
||||
var remainingChars = word.substr(max);
|
||||
|
||||
var splitIndex = firstLine.lastIndexOf(wrapCharacters[idx]);
|
||||
|
||||
if (splitIndex > -1) {
|
||||
// We've found a character to split on, store before the split then check if we
|
||||
// need to split again
|
||||
word = firstLine.substr(splitIndex + 1) + remainingChars;
|
||||
fuseWord.push(firstLine.substr(0, splitIndex + 1));
|
||||
} else {
|
||||
idx++;
|
||||
if (idx >= wrapCharacters.length) {
|
||||
// Cannot split on character, so either split at 'max' or preserve length
|
||||
if (forceWrapOnLimit) {
|
||||
fuseWord.push(firstLine);
|
||||
word = remainingChars;
|
||||
if (word.length > max) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
word = firstLine + remainingChars;
|
||||
if (!options.preserveNewlines) {
|
||||
word += '\n';
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
word = firstLine + remainingChars;
|
||||
}
|
||||
}
|
||||
}
|
||||
fuseWord.push(word);
|
||||
|
||||
return fuseWord.join('\n');
|
||||
}
|
||||
|
||||
exports.wordwrap = function wordwrap(text, options) {
|
||||
var max = options.wordwrap;
|
||||
var preserveNewlines = options.preserveNewlines;
|
||||
var length = options.lineCharCount;
|
||||
|
||||
// Preserve leading space
|
||||
var result = text.startsWith(' ') ? ' ' : '';
|
||||
length += result.length;
|
||||
var buffer = [];
|
||||
// Split the text into words, decide to preserve new lines or not.
|
||||
var words = preserveNewlines
|
||||
? text.trim().replace(/\n/g, '\n ').split(/\ +/)
|
||||
: text.trim().split(/\s+/);
|
||||
|
||||
// Determine where to end line word by word.
|
||||
words.forEach(function(word) {
|
||||
// Add buffer to result if we can't fit any more words in the buffer.
|
||||
if ((max || max === 0) && length > 0 && ((length + word.length > max) || (length + word.indexOf('\n') > max))) {
|
||||
// Concat buffer and add it to the result
|
||||
result += buffer.join(' ') + '\n';
|
||||
// Reset buffer and length
|
||||
buffer.length = length = 0;
|
||||
}
|
||||
|
||||
// Check if the current word is long enough to be wrapped
|
||||
if ((max || max === 0) && (options.longWordSplit) && (word.length > max)) {
|
||||
word = splitLongWord(word, options);
|
||||
}
|
||||
|
||||
buffer.push(word);
|
||||
|
||||
// If the word contains a newline then restart the count and add the buffer to the result
|
||||
if (word.indexOf('\n') !== -1) {
|
||||
result += buffer.join(' ');
|
||||
|
||||
// Reset the buffer, let the length include any characters after the last newline
|
||||
buffer.length = 0;
|
||||
length = word.length - (word.lastIndexOf('\n') + 1);
|
||||
// If there are characters after the newline, add a space and increase the length by 1
|
||||
if (length) {
|
||||
result += ' ';
|
||||
length++;
|
||||
}
|
||||
} else {
|
||||
// Add word length + one whitespace
|
||||
length += word.length + 1;
|
||||
}
|
||||
});
|
||||
// Add the rest to the result.
|
||||
result += buffer.join(' ');
|
||||
|
||||
// Preserve trailing space
|
||||
if (!text.endsWith(' ')) {
|
||||
result = trimEnd(result);
|
||||
} else if (!result.endsWith(' ')) {
|
||||
result = result + ' ';
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.arrayZip = function arrayZip(array) {
|
||||
return zip.apply(null, array);
|
||||
};
|
||||
|
||||
exports.splitCssSearchTag = function splitCssSearchTag(tagString) {
|
||||
function getParams(re, string) {
|
||||
var captures = [], found;
|
||||
while ((found = re.exec(string)) !== null) {
|
||||
captures.push(found[1]);
|
||||
}
|
||||
return captures;
|
||||
}
|
||||
|
||||
var splitTag = {};
|
||||
var elementRe = /(^\w*)/g;
|
||||
splitTag.element = elementRe.exec(tagString)[1];
|
||||
splitTag.classes = getParams( /\.([\d\w-]*)/g, tagString);
|
||||
splitTag.ids = getParams( /#([\d\w-]*)/g, tagString);
|
||||
|
||||
return splitTag;
|
||||
};
|
||||
|
||||
exports.replaceAll = function replaceAll(str, find, replace) {
|
||||
var reg = new RegExp(find, 'g');
|
||||
|
||||
return str.replace(reg, replace);
|
||||
};
|
||||
188
nodered/rootfs/data/node_modules/html-to-text/lib/html-to-text.js
generated
vendored
Normal file
188
nodered/rootfs/data/node_modules/html-to-text/lib/html-to-text.js
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
var includes = require('lodash/includes');
|
||||
var trimEnd = require('lodash/trimEnd');
|
||||
var htmlparser = require('htmlparser2');
|
||||
|
||||
var helper = require('./helper');
|
||||
var defaultFormat = require('./formatter');
|
||||
|
||||
// Which type of tags should not be parsed
|
||||
var SKIP_TYPES = [
|
||||
'style',
|
||||
'script'
|
||||
];
|
||||
|
||||
function htmlToText(html, options) {
|
||||
options = Object.assign({
|
||||
wordwrap: 80,
|
||||
tables: [],
|
||||
preserveNewlines: false,
|
||||
uppercaseHeadings: true,
|
||||
singleNewLineParagraphs: false,
|
||||
hideLinkHrefIfSameAsText: false,
|
||||
linkHrefBaseUrl: null,
|
||||
noLinkBrackets: false,
|
||||
noAnchorUrl: true,
|
||||
baseElement: 'body',
|
||||
returnDomByDefault: true,
|
||||
format: {},
|
||||
decodeOptions: {
|
||||
isAttributeValue: false,
|
||||
strict: false
|
||||
},
|
||||
longWordSplit: {
|
||||
wrapCharacters: [],
|
||||
forceWrapOnLimit: false
|
||||
},
|
||||
unorderedListItemPrefix: ' * '
|
||||
}, options || {});
|
||||
|
||||
var handler = new htmlparser.DefaultHandler(function (error, dom) {
|
||||
|
||||
}, {
|
||||
verbose: true
|
||||
});
|
||||
new htmlparser.Parser(handler).parseComplete(html);
|
||||
|
||||
options.lineCharCount = 0;
|
||||
|
||||
var result = '';
|
||||
var baseElements = Array.isArray(options.baseElement) ? options.baseElement : [options.baseElement];
|
||||
for (var idx = 0; idx < baseElements.length; ++idx) {
|
||||
result += walk(filterBody(handler.dom, options, baseElements[idx]), options);
|
||||
}
|
||||
return trimEnd(result);
|
||||
}
|
||||
|
||||
function filterBody(dom, options, baseElement) {
|
||||
var result = null;
|
||||
|
||||
var splitTag = helper.splitCssSearchTag(baseElement);
|
||||
|
||||
function walk(dom) {
|
||||
if (result) return;
|
||||
dom.forEach(function(elem) {
|
||||
if (result) return;
|
||||
if (elem.name === splitTag.element) {
|
||||
var documentClasses = elem.attribs && elem.attribs.class ? elem.attribs.class.split(" ") : [];
|
||||
var documentIds = elem.attribs && elem.attribs.id ? elem.attribs.id.split(" ") : [];
|
||||
|
||||
if ((splitTag.classes.every(function (val) { return documentClasses.indexOf(val) >= 0; })) &&
|
||||
(splitTag.ids.every(function (val) { return documentIds.indexOf(val) >= 0; }))) {
|
||||
result = [elem];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (elem.children) walk(elem.children);
|
||||
});
|
||||
}
|
||||
walk(dom);
|
||||
return options.returnDomByDefault ? result || dom : result;
|
||||
}
|
||||
|
||||
function containsTable(attr, tables) {
|
||||
if (tables === true) return true;
|
||||
|
||||
function removePrefix(key) {
|
||||
return key.substr(1);
|
||||
}
|
||||
function checkPrefix(prefix) {
|
||||
return function(key) {
|
||||
return key.startsWith(prefix);
|
||||
};
|
||||
}
|
||||
function filterByPrefix(tables, prefix) {
|
||||
return tables
|
||||
.filter(checkPrefix(prefix))
|
||||
.map(removePrefix);
|
||||
}
|
||||
var classes = filterByPrefix(tables, '.');
|
||||
var ids = filterByPrefix(tables, '#');
|
||||
return attr && (includes(classes, attr['class']) || includes(ids, attr['id']));
|
||||
}
|
||||
|
||||
function walk(dom, options, result) {
|
||||
if (arguments.length < 3) {
|
||||
result = '';
|
||||
}
|
||||
var whiteSpaceRegex = /\s$/;
|
||||
var format = Object.assign({}, defaultFormat, options.format);
|
||||
|
||||
if (!dom) {
|
||||
return result;
|
||||
}
|
||||
|
||||
dom.forEach(function(elem) {
|
||||
switch(elem.type) {
|
||||
case 'tag':
|
||||
switch(elem.name.toLowerCase()) {
|
||||
case 'img':
|
||||
result += format.image(elem, options);
|
||||
break;
|
||||
case 'a':
|
||||
// Inline element needs its leading space to be trimmed if `result`
|
||||
// currently ends with whitespace
|
||||
elem.trimLeadingSpace = whiteSpaceRegex.test(result);
|
||||
result += format.anchor(elem, walk, options);
|
||||
break;
|
||||
case 'p':
|
||||
result += format.paragraph(elem, walk, options);
|
||||
break;
|
||||
case 'h1':
|
||||
case 'h2':
|
||||
case 'h3':
|
||||
case 'h4':
|
||||
case 'h5':
|
||||
case 'h6':
|
||||
result += format.heading(elem, walk, options);
|
||||
break;
|
||||
case 'br':
|
||||
result += format.lineBreak(elem, walk, options);
|
||||
break;
|
||||
case 'hr':
|
||||
result += format.horizontalLine(elem, walk, options);
|
||||
break;
|
||||
case 'ul':
|
||||
result += format.unorderedList(elem, walk, options);
|
||||
break;
|
||||
case 'ol':
|
||||
result += format.orderedList(elem, walk, options);
|
||||
break;
|
||||
case 'pre':
|
||||
var newOptions = Object.assign({}, options);
|
||||
newOptions.isInPre = true;
|
||||
result += format.paragraph(elem, walk, newOptions);
|
||||
break;
|
||||
case 'table':
|
||||
result = containsTable(elem.attribs, options.tables)
|
||||
? result + format.table(elem, walk, options)
|
||||
: walk(elem.children || [], options, result);
|
||||
break;
|
||||
case 'blockquote':
|
||||
result += format.blockquote(elem, walk, options);
|
||||
break;
|
||||
default:
|
||||
result = walk(elem.children || [], options, result);
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
if (elem.data !== '\r\n') {
|
||||
// Text needs its leading space to be trimmed if `result`
|
||||
// currently ends with whitespace
|
||||
elem.trimLeadingSpace = whiteSpaceRegex.test(result);
|
||||
result += format.text(elem, options);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!includes(SKIP_TYPES, elem.type)) {
|
||||
result = walk(elem.children || [], options, result);
|
||||
}
|
||||
}
|
||||
|
||||
options.lineCharCount = result.length - (result.lastIndexOf('\n') + 1);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.fromString = function(str, options) {
|
||||
return htmlToText(str, options || {});
|
||||
};
|
||||
8
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/.travis.yml
generated
vendored
Normal file
8
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
before_install:
|
||||
- npm install -g npm@~1.4.6
|
||||
18
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/LICENSE
generated
vendored
Normal file
18
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
2
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/example/parse.js
generated
vendored
Normal file
2
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/example/parse.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var argv = require('../')(process.argv.slice(2));
|
||||
console.dir(argv);
|
||||
236
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/index.js
generated
vendored
Normal file
236
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/index.js
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
module.exports = function (args, opts) {
|
||||
if (!opts) opts = {};
|
||||
|
||||
var flags = { bools : {}, strings : {}, unknownFn: null };
|
||||
|
||||
if (typeof opts['unknown'] === 'function') {
|
||||
flags.unknownFn = opts['unknown'];
|
||||
}
|
||||
|
||||
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
|
||||
flags.allBools = true;
|
||||
} else {
|
||||
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
|
||||
flags.bools[key] = true;
|
||||
});
|
||||
}
|
||||
|
||||
var aliases = {};
|
||||
Object.keys(opts.alias || {}).forEach(function (key) {
|
||||
aliases[key] = [].concat(opts.alias[key]);
|
||||
aliases[key].forEach(function (x) {
|
||||
aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
||||
return x !== y;
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
||||
flags.strings[key] = true;
|
||||
if (aliases[key]) {
|
||||
flags.strings[aliases[key]] = true;
|
||||
}
|
||||
});
|
||||
|
||||
var defaults = opts['default'] || {};
|
||||
|
||||
var argv = { _ : [] };
|
||||
Object.keys(flags.bools).forEach(function (key) {
|
||||
setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
||||
});
|
||||
|
||||
var notFlags = [];
|
||||
|
||||
if (args.indexOf('--') !== -1) {
|
||||
notFlags = args.slice(args.indexOf('--')+1);
|
||||
args = args.slice(0, args.indexOf('--'));
|
||||
}
|
||||
|
||||
function argDefined(key, arg) {
|
||||
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
|
||||
flags.strings[key] || flags.bools[key] || aliases[key];
|
||||
}
|
||||
|
||||
function setArg (key, val, arg) {
|
||||
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
||||
if (flags.unknownFn(arg) === false) return;
|
||||
}
|
||||
|
||||
var value = !flags.strings[key] && isNumber(val)
|
||||
? Number(val) : val
|
||||
;
|
||||
setKey(argv, key.split('.'), value);
|
||||
|
||||
(aliases[key] || []).forEach(function (x) {
|
||||
setKey(argv, x.split('.'), value);
|
||||
});
|
||||
}
|
||||
|
||||
function setKey (obj, keys, value) {
|
||||
var o = obj;
|
||||
keys.slice(0,-1).forEach(function (key) {
|
||||
if (o[key] === undefined) o[key] = {};
|
||||
o = o[key];
|
||||
});
|
||||
|
||||
var key = keys[keys.length - 1];
|
||||
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
|
||||
o[key] = value;
|
||||
}
|
||||
else if (Array.isArray(o[key])) {
|
||||
o[key].push(value);
|
||||
}
|
||||
else {
|
||||
o[key] = [ o[key], value ];
|
||||
}
|
||||
}
|
||||
|
||||
function aliasIsBoolean(key) {
|
||||
return aliases[key].some(function (x) {
|
||||
return flags.bools[x];
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var arg = args[i];
|
||||
|
||||
if (/^--.+=/.test(arg)) {
|
||||
// Using [\s\S] instead of . because js doesn't support the
|
||||
// 'dotall' regex modifier. See:
|
||||
// http://stackoverflow.com/a/1068308/13216
|
||||
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
||||
var key = m[1];
|
||||
var value = m[2];
|
||||
if (flags.bools[key]) {
|
||||
value = value !== 'false';
|
||||
}
|
||||
setArg(key, value, arg);
|
||||
}
|
||||
else if (/^--no-.+/.test(arg)) {
|
||||
var key = arg.match(/^--no-(.+)/)[1];
|
||||
setArg(key, false, arg);
|
||||
}
|
||||
else if (/^--.+/.test(arg)) {
|
||||
var key = arg.match(/^--(.+)/)[1];
|
||||
var next = args[i + 1];
|
||||
if (next !== undefined && !/^-/.test(next)
|
||||
&& !flags.bools[key]
|
||||
&& !flags.allBools
|
||||
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
||||
setArg(key, next, arg);
|
||||
i++;
|
||||
}
|
||||
else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key, next === 'true', arg);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
setArg(key, flags.strings[key] ? '' : true, arg);
|
||||
}
|
||||
}
|
||||
else if (/^-[^-]+/.test(arg)) {
|
||||
var letters = arg.slice(1,-1).split('');
|
||||
|
||||
var broken = false;
|
||||
for (var j = 0; j < letters.length; j++) {
|
||||
var next = arg.slice(j+2);
|
||||
|
||||
if (next === '-') {
|
||||
setArg(letters[j], next, arg)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
|
||||
setArg(letters[j], next.split('=')[1], arg);
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (/[A-Za-z]/.test(letters[j])
|
||||
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
||||
setArg(letters[j], next, arg);
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (letters[j+1] && letters[j+1].match(/\W/)) {
|
||||
setArg(letters[j], arg.slice(j+2), arg);
|
||||
broken = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
||||
}
|
||||
}
|
||||
|
||||
var key = arg.slice(-1)[0];
|
||||
if (!broken && key !== '-') {
|
||||
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
|
||||
&& !flags.bools[key]
|
||||
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
||||
setArg(key, args[i+1], arg);
|
||||
i++;
|
||||
}
|
||||
else if (args[i+1] && /true|false/.test(args[i+1])) {
|
||||
setArg(key, args[i+1] === 'true', arg);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
setArg(key, flags.strings[key] ? '' : true, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
||||
argv._.push(
|
||||
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
|
||||
);
|
||||
}
|
||||
if (opts.stopEarly) {
|
||||
argv._.push.apply(argv._, args.slice(i + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(defaults).forEach(function (key) {
|
||||
if (!hasKey(argv, key.split('.'))) {
|
||||
setKey(argv, key.split('.'), defaults[key]);
|
||||
|
||||
(aliases[key] || []).forEach(function (x) {
|
||||
setKey(argv, x.split('.'), defaults[key]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (opts['--']) {
|
||||
argv['--'] = new Array();
|
||||
notFlags.forEach(function(key) {
|
||||
argv['--'].push(key);
|
||||
});
|
||||
}
|
||||
else {
|
||||
notFlags.forEach(function(key) {
|
||||
argv._.push(key);
|
||||
});
|
||||
}
|
||||
|
||||
return argv;
|
||||
};
|
||||
|
||||
function hasKey (obj, keys) {
|
||||
var o = obj;
|
||||
keys.slice(0,-1).forEach(function (key) {
|
||||
o = (o[key] || {});
|
||||
});
|
||||
|
||||
var key = keys[keys.length - 1];
|
||||
return key in o;
|
||||
}
|
||||
|
||||
function isNumber (x) {
|
||||
if (typeof x === 'number') return true;
|
||||
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
||||
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
||||
}
|
||||
|
||||
73
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/package.json
generated
vendored
Normal file
73
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"_from": "minimist@^1.2.0",
|
||||
"_id": "minimist@1.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"_location": "/html-to-text/minimist",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "minimist@^1.2.0",
|
||||
"name": "minimist",
|
||||
"escapedName": "minimist",
|
||||
"rawSpec": "^1.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/html-to-text"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"_shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
|
||||
"_spec": "minimist@^1.2.0",
|
||||
"_where": "/data/node_modules/html-to-text",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/minimist/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "parse argument options",
|
||||
"devDependencies": {
|
||||
"covert": "^1.0.0",
|
||||
"tap": "~0.4.0",
|
||||
"tape": "^3.5.0"
|
||||
},
|
||||
"homepage": "https://github.com/substack/minimist",
|
||||
"keywords": [
|
||||
"argv",
|
||||
"getopt",
|
||||
"parser",
|
||||
"optimist"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "minimist",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/minimist.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "covert test/*.js",
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"ff/5",
|
||||
"firefox/latest",
|
||||
"chrome/10",
|
||||
"chrome/latest",
|
||||
"safari/5.1",
|
||||
"safari/latest",
|
||||
"opera/12"
|
||||
]
|
||||
},
|
||||
"version": "1.2.0"
|
||||
}
|
||||
91
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/readme.markdown
generated
vendored
Normal file
91
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
# minimist
|
||||
|
||||
parse argument options
|
||||
|
||||
This module is the guts of optimist's argument parser without all the
|
||||
fanciful decoration.
|
||||
|
||||
[](http://ci.testling.com/substack/minimist)
|
||||
|
||||
[](http://travis-ci.org/substack/minimist)
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
console.dir(argv);
|
||||
```
|
||||
|
||||
```
|
||||
$ node example/parse.js -a beep -b boop
|
||||
{ _: [], a: 'beep', b: 'boop' }
|
||||
```
|
||||
|
||||
```
|
||||
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
|
||||
{ _: [ 'foo', 'bar', 'baz' ],
|
||||
x: 3,
|
||||
y: 4,
|
||||
n: 5,
|
||||
a: true,
|
||||
b: true,
|
||||
c: true,
|
||||
beep: 'boop' }
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var parseArgs = require('minimist')
|
||||
```
|
||||
|
||||
## var argv = parseArgs(args, opts={})
|
||||
|
||||
Return an argument object `argv` populated with the array arguments from `args`.
|
||||
|
||||
`argv._` contains all the arguments that didn't have an option associated with
|
||||
them.
|
||||
|
||||
Numeric-looking arguments will be returned as numbers unless `opts.string` or
|
||||
`opts.boolean` is set for that argument name.
|
||||
|
||||
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
|
||||
|
||||
options can be:
|
||||
|
||||
* `opts.string` - a string or array of strings argument names to always treat as
|
||||
strings
|
||||
* `opts.boolean` - a boolean, string or array of strings to always treat as
|
||||
booleans. if `true` will treat all double hyphenated arguments without equal signs
|
||||
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
|
||||
* `opts.alias` - an object mapping string names to strings or arrays of string
|
||||
argument names to use as aliases
|
||||
* `opts.default` - an object mapping string argument names to default values
|
||||
* `opts.stopEarly` - when true, populate `argv._` with everything after the
|
||||
first non-option
|
||||
* `opts['--']` - when true, populate `argv._` with everything before the `--`
|
||||
and `argv['--']` with everything after the `--`. Here's an example:
|
||||
* `opts.unknown` - a function which is invoked with a command line parameter not
|
||||
defined in the `opts` configuration object. If the function returns `false`, the
|
||||
unknown option is not added to `argv`.
|
||||
|
||||
```
|
||||
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
|
||||
{ _: [ 'one', 'two', 'three' ],
|
||||
'--': [ 'four', 'five', '--six' ] }
|
||||
```
|
||||
|
||||
Note that with `opts['--']` set, parsing for arguments still stops after the
|
||||
`--`.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install minimist
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
32
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/all_bool.js
generated
vendored
Normal file
32
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/all_bool.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('flag boolean true (default all --args to boolean)', function (t) {
|
||||
var argv = parse(['moo', '--honk', 'cow'], {
|
||||
boolean: true
|
||||
});
|
||||
|
||||
t.deepEqual(argv, {
|
||||
honk: true,
|
||||
_: ['moo', 'cow']
|
||||
});
|
||||
|
||||
t.deepEqual(typeof argv.honk, 'boolean');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
|
||||
var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
|
||||
boolean: true
|
||||
});
|
||||
|
||||
t.deepEqual(argv, {
|
||||
honk: true,
|
||||
tacos: 'good',
|
||||
p: 55,
|
||||
_: ['moo', 'cow']
|
||||
});
|
||||
|
||||
t.deepEqual(typeof argv.honk, 'boolean');
|
||||
t.end();
|
||||
});
|
||||
166
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/bool.js
generated
vendored
Normal file
166
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/bool.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('flag boolean default false', function (t) {
|
||||
var argv = parse(['moo'], {
|
||||
boolean: ['t', 'verbose'],
|
||||
default: { verbose: false, t: false }
|
||||
});
|
||||
|
||||
t.deepEqual(argv, {
|
||||
verbose: false,
|
||||
t: false,
|
||||
_: ['moo']
|
||||
});
|
||||
|
||||
t.deepEqual(typeof argv.verbose, 'boolean');
|
||||
t.deepEqual(typeof argv.t, 'boolean');
|
||||
t.end();
|
||||
|
||||
});
|
||||
|
||||
test('boolean groups', function (t) {
|
||||
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
|
||||
boolean: ['x','y','z']
|
||||
});
|
||||
|
||||
t.deepEqual(argv, {
|
||||
x : true,
|
||||
y : false,
|
||||
z : true,
|
||||
_ : [ 'one', 'two', 'three' ]
|
||||
});
|
||||
|
||||
t.deepEqual(typeof argv.x, 'boolean');
|
||||
t.deepEqual(typeof argv.y, 'boolean');
|
||||
t.deepEqual(typeof argv.z, 'boolean');
|
||||
t.end();
|
||||
});
|
||||
test('boolean and alias with chainable api', function (t) {
|
||||
var aliased = [ '-h', 'derp' ];
|
||||
var regular = [ '--herp', 'derp' ];
|
||||
var opts = {
|
||||
herp: { alias: 'h', boolean: true }
|
||||
};
|
||||
var aliasedArgv = parse(aliased, {
|
||||
boolean: 'herp',
|
||||
alias: { h: 'herp' }
|
||||
});
|
||||
var propertyArgv = parse(regular, {
|
||||
boolean: 'herp',
|
||||
alias: { h: 'herp' }
|
||||
});
|
||||
var expected = {
|
||||
herp: true,
|
||||
h: true,
|
||||
'_': [ 'derp' ]
|
||||
};
|
||||
|
||||
t.same(aliasedArgv, expected);
|
||||
t.same(propertyArgv, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean and alias with options hash', function (t) {
|
||||
var aliased = [ '-h', 'derp' ];
|
||||
var regular = [ '--herp', 'derp' ];
|
||||
var opts = {
|
||||
alias: { 'h': 'herp' },
|
||||
boolean: 'herp'
|
||||
};
|
||||
var aliasedArgv = parse(aliased, opts);
|
||||
var propertyArgv = parse(regular, opts);
|
||||
var expected = {
|
||||
herp: true,
|
||||
h: true,
|
||||
'_': [ 'derp' ]
|
||||
};
|
||||
t.same(aliasedArgv, expected);
|
||||
t.same(propertyArgv, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean and alias array with options hash', function (t) {
|
||||
var aliased = [ '-h', 'derp' ];
|
||||
var regular = [ '--herp', 'derp' ];
|
||||
var alt = [ '--harp', 'derp' ];
|
||||
var opts = {
|
||||
alias: { 'h': ['herp', 'harp'] },
|
||||
boolean: 'h'
|
||||
};
|
||||
var aliasedArgv = parse(aliased, opts);
|
||||
var propertyArgv = parse(regular, opts);
|
||||
var altPropertyArgv = parse(alt, opts);
|
||||
var expected = {
|
||||
harp: true,
|
||||
herp: true,
|
||||
h: true,
|
||||
'_': [ 'derp' ]
|
||||
};
|
||||
t.same(aliasedArgv, expected);
|
||||
t.same(propertyArgv, expected);
|
||||
t.same(altPropertyArgv, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean and alias using explicit true', function (t) {
|
||||
var aliased = [ '-h', 'true' ];
|
||||
var regular = [ '--herp', 'true' ];
|
||||
var opts = {
|
||||
alias: { h: 'herp' },
|
||||
boolean: 'h'
|
||||
};
|
||||
var aliasedArgv = parse(aliased, opts);
|
||||
var propertyArgv = parse(regular, opts);
|
||||
var expected = {
|
||||
herp: true,
|
||||
h: true,
|
||||
'_': [ ]
|
||||
};
|
||||
|
||||
t.same(aliasedArgv, expected);
|
||||
t.same(propertyArgv, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
// regression, see https://github.com/substack/node-optimist/issues/71
|
||||
test('boolean and --x=true', function(t) {
|
||||
var parsed = parse(['--boool', '--other=true'], {
|
||||
boolean: 'boool'
|
||||
});
|
||||
|
||||
t.same(parsed.boool, true);
|
||||
t.same(parsed.other, 'true');
|
||||
|
||||
parsed = parse(['--boool', '--other=false'], {
|
||||
boolean: 'boool'
|
||||
});
|
||||
|
||||
t.same(parsed.boool, true);
|
||||
t.same(parsed.other, 'false');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean --boool=true', function (t) {
|
||||
var parsed = parse(['--boool=true'], {
|
||||
default: {
|
||||
boool: false
|
||||
},
|
||||
boolean: ['boool']
|
||||
});
|
||||
|
||||
t.same(parsed.boool, true);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean --boool=false', function (t) {
|
||||
var parsed = parse(['--boool=false'], {
|
||||
default: {
|
||||
boool: true
|
||||
},
|
||||
boolean: ['boool']
|
||||
});
|
||||
|
||||
t.same(parsed.boool, false);
|
||||
t.end();
|
||||
});
|
||||
31
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/dash.js
generated
vendored
Normal file
31
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/dash.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('-', function (t) {
|
||||
t.plan(5);
|
||||
t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] });
|
||||
t.deepEqual(parse([ '-' ]), { _: [ '-' ] });
|
||||
t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] });
|
||||
t.deepEqual(
|
||||
parse([ '-b', '-' ], { boolean: 'b' }),
|
||||
{ b: true, _: [ '-' ] }
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '-s', '-' ], { string: 's' }),
|
||||
{ s: '-', _: [] }
|
||||
);
|
||||
});
|
||||
|
||||
test('-a -- b', function (t) {
|
||||
t.plan(3);
|
||||
t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] });
|
||||
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
|
||||
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
|
||||
});
|
||||
|
||||
test('move arguments after the -- into their own `--` array', function(t) {
|
||||
t.plan(1);
|
||||
t.deepEqual(
|
||||
parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }),
|
||||
{ name: 'John', _: [ 'before' ], '--': [ 'after' ] });
|
||||
});
|
||||
35
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/default_bool.js
generated
vendored
Normal file
35
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/default_bool.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
var test = require('tape');
|
||||
var parse = require('../');
|
||||
|
||||
test('boolean default true', function (t) {
|
||||
var argv = parse([], {
|
||||
boolean: 'sometrue',
|
||||
default: { sometrue: true }
|
||||
});
|
||||
t.equal(argv.sometrue, true);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean default false', function (t) {
|
||||
var argv = parse([], {
|
||||
boolean: 'somefalse',
|
||||
default: { somefalse: false }
|
||||
});
|
||||
t.equal(argv.somefalse, false);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('boolean default to null', function (t) {
|
||||
var argv = parse([], {
|
||||
boolean: 'maybe',
|
||||
default: { maybe: null }
|
||||
});
|
||||
t.equal(argv.maybe, null);
|
||||
var argv = parse(['--maybe'], {
|
||||
boolean: 'maybe',
|
||||
default: { maybe: null }
|
||||
});
|
||||
t.equal(argv.maybe, true);
|
||||
t.end();
|
||||
|
||||
})
|
||||
22
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/dotted.js
generated
vendored
Normal file
22
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/dotted.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('dotted alias', function (t) {
|
||||
var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
|
||||
t.equal(argv.a.b, 22);
|
||||
t.equal(argv.aa.bb, 22);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('dotted default', function (t) {
|
||||
var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
|
||||
t.equal(argv.a.b, 11);
|
||||
t.equal(argv.aa.bb, 11);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('dotted default with no alias', function (t) {
|
||||
var argv = parse('', {default: {'a.b': 11}});
|
||||
t.equal(argv.a.b, 11);
|
||||
t.end();
|
||||
});
|
||||
16
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/kv_short.js
generated
vendored
Normal file
16
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/kv_short.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('short -k=v' , function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var argv = parse([ '-b=123' ]);
|
||||
t.deepEqual(argv, { b: 123, _: [] });
|
||||
});
|
||||
|
||||
test('multi short -k=v' , function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var argv = parse([ '-a=whatever', '-b=robots' ]);
|
||||
t.deepEqual(argv, { a: 'whatever', b: 'robots', _: [] });
|
||||
});
|
||||
31
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/long.js
generated
vendored
Normal file
31
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/long.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var test = require('tape');
|
||||
var parse = require('../');
|
||||
|
||||
test('long opts', function (t) {
|
||||
t.deepEqual(
|
||||
parse([ '--bool' ]),
|
||||
{ bool : true, _ : [] },
|
||||
'long boolean'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '--pow', 'xixxle' ]),
|
||||
{ pow : 'xixxle', _ : [] },
|
||||
'long capture sp'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '--pow=xixxle' ]),
|
||||
{ pow : 'xixxle', _ : [] },
|
||||
'long capture eq'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '--host', 'localhost', '--port', '555' ]),
|
||||
{ host : 'localhost', port : 555, _ : [] },
|
||||
'long captures sp'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '--host=localhost', '--port=555' ]),
|
||||
{ host : 'localhost', port : 555, _ : [] },
|
||||
'long captures eq'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
36
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/num.js
generated
vendored
Normal file
36
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/num.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('nums', function (t) {
|
||||
var argv = parse([
|
||||
'-x', '1234',
|
||||
'-y', '5.67',
|
||||
'-z', '1e7',
|
||||
'-w', '10f',
|
||||
'--hex', '0xdeadbeef',
|
||||
'789'
|
||||
]);
|
||||
t.deepEqual(argv, {
|
||||
x : 1234,
|
||||
y : 5.67,
|
||||
z : 1e7,
|
||||
w : '10f',
|
||||
hex : 0xdeadbeef,
|
||||
_ : [ 789 ]
|
||||
});
|
||||
t.deepEqual(typeof argv.x, 'number');
|
||||
t.deepEqual(typeof argv.y, 'number');
|
||||
t.deepEqual(typeof argv.z, 'number');
|
||||
t.deepEqual(typeof argv.w, 'string');
|
||||
t.deepEqual(typeof argv.hex, 'number');
|
||||
t.deepEqual(typeof argv._[0], 'number');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('already a number', function (t) {
|
||||
var argv = parse([ '-x', 1234, 789 ]);
|
||||
t.deepEqual(argv, { x : 1234, _ : [ 789 ] });
|
||||
t.deepEqual(typeof argv.x, 'number');
|
||||
t.deepEqual(typeof argv._[0], 'number');
|
||||
t.end();
|
||||
});
|
||||
197
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/parse.js
generated
vendored
Normal file
197
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/parse.js
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('parse args', function (t) {
|
||||
t.deepEqual(
|
||||
parse([ '--no-moo' ]),
|
||||
{ moo : false, _ : [] },
|
||||
'no'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),
|
||||
{ v : ['a','b','c'], _ : [] },
|
||||
'multi'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('comprehensive', function (t) {
|
||||
t.deepEqual(
|
||||
parse([
|
||||
'--name=meowmers', 'bare', '-cats', 'woo',
|
||||
'-h', 'awesome', '--multi=quux',
|
||||
'--key', 'value',
|
||||
'-b', '--bool', '--no-meep', '--multi=baz',
|
||||
'--', '--not-a-flag', 'eek'
|
||||
]),
|
||||
{
|
||||
c : true,
|
||||
a : true,
|
||||
t : true,
|
||||
s : 'woo',
|
||||
h : 'awesome',
|
||||
b : true,
|
||||
bool : true,
|
||||
key : 'value',
|
||||
multi : [ 'quux', 'baz' ],
|
||||
meep : false,
|
||||
name : 'meowmers',
|
||||
_ : [ 'bare', '--not-a-flag', 'eek' ]
|
||||
}
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('flag boolean', function (t) {
|
||||
var argv = parse([ '-t', 'moo' ], { boolean: 't' });
|
||||
t.deepEqual(argv, { t : true, _ : [ 'moo' ] });
|
||||
t.deepEqual(typeof argv.t, 'boolean');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('flag boolean value', function (t) {
|
||||
var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], {
|
||||
boolean: [ 't', 'verbose' ],
|
||||
default: { verbose: true }
|
||||
});
|
||||
|
||||
t.deepEqual(argv, {
|
||||
verbose: false,
|
||||
t: true,
|
||||
_: ['moo']
|
||||
});
|
||||
|
||||
t.deepEqual(typeof argv.verbose, 'boolean');
|
||||
t.deepEqual(typeof argv.t, 'boolean');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('newlines in params' , function (t) {
|
||||
var args = parse([ '-s', "X\nX" ])
|
||||
t.deepEqual(args, { _ : [], s : "X\nX" });
|
||||
|
||||
// reproduce in bash:
|
||||
// VALUE="new
|
||||
// line"
|
||||
// node program.js --s="$VALUE"
|
||||
args = parse([ "--s=X\nX" ])
|
||||
t.deepEqual(args, { _ : [], s : "X\nX" });
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('strings' , function (t) {
|
||||
var s = parse([ '-s', '0001234' ], { string: 's' }).s;
|
||||
t.equal(s, '0001234');
|
||||
t.equal(typeof s, 'string');
|
||||
|
||||
var x = parse([ '-x', '56' ], { string: 'x' }).x;
|
||||
t.equal(x, '56');
|
||||
t.equal(typeof x, 'string');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('stringArgs', function (t) {
|
||||
var s = parse([ ' ', ' ' ], { string: '_' })._;
|
||||
t.same(s.length, 2);
|
||||
t.same(typeof s[0], 'string');
|
||||
t.same(s[0], ' ');
|
||||
t.same(typeof s[1], 'string');
|
||||
t.same(s[1], ' ');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('empty strings', function(t) {
|
||||
var s = parse([ '-s' ], { string: 's' }).s;
|
||||
t.equal(s, '');
|
||||
t.equal(typeof s, 'string');
|
||||
|
||||
var str = parse([ '--str' ], { string: 'str' }).str;
|
||||
t.equal(str, '');
|
||||
t.equal(typeof str, 'string');
|
||||
|
||||
var letters = parse([ '-art' ], {
|
||||
string: [ 'a', 't' ]
|
||||
});
|
||||
|
||||
t.equal(letters.a, '');
|
||||
t.equal(letters.r, true);
|
||||
t.equal(letters.t, '');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('string and alias', function(t) {
|
||||
var x = parse([ '--str', '000123' ], {
|
||||
string: 's',
|
||||
alias: { s: 'str' }
|
||||
});
|
||||
|
||||
t.equal(x.str, '000123');
|
||||
t.equal(typeof x.str, 'string');
|
||||
t.equal(x.s, '000123');
|
||||
t.equal(typeof x.s, 'string');
|
||||
|
||||
var y = parse([ '-s', '000123' ], {
|
||||
string: 'str',
|
||||
alias: { str: 's' }
|
||||
});
|
||||
|
||||
t.equal(y.str, '000123');
|
||||
t.equal(typeof y.str, 'string');
|
||||
t.equal(y.s, '000123');
|
||||
t.equal(typeof y.s, 'string');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('slashBreak', function (t) {
|
||||
t.same(
|
||||
parse([ '-I/foo/bar/baz' ]),
|
||||
{ I : '/foo/bar/baz', _ : [] }
|
||||
);
|
||||
t.same(
|
||||
parse([ '-xyz/foo/bar/baz' ]),
|
||||
{ x : true, y : true, z : '/foo/bar/baz', _ : [] }
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('alias', function (t) {
|
||||
var argv = parse([ '-f', '11', '--zoom', '55' ], {
|
||||
alias: { z: 'zoom' }
|
||||
});
|
||||
t.equal(argv.zoom, 55);
|
||||
t.equal(argv.z, argv.zoom);
|
||||
t.equal(argv.f, 11);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('multiAlias', function (t) {
|
||||
var argv = parse([ '-f', '11', '--zoom', '55' ], {
|
||||
alias: { z: [ 'zm', 'zoom' ] }
|
||||
});
|
||||
t.equal(argv.zoom, 55);
|
||||
t.equal(argv.z, argv.zoom);
|
||||
t.equal(argv.z, argv.zm);
|
||||
t.equal(argv.f, 11);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('nested dotted objects', function (t) {
|
||||
var argv = parse([
|
||||
'--foo.bar', '3', '--foo.baz', '4',
|
||||
'--foo.quux.quibble', '5', '--foo.quux.o_O',
|
||||
'--beep.boop'
|
||||
]);
|
||||
|
||||
t.same(argv.foo, {
|
||||
bar : 3,
|
||||
baz : 4,
|
||||
quux : {
|
||||
quibble : 5,
|
||||
o_O : true
|
||||
}
|
||||
});
|
||||
t.same(argv.beep, { boop : true });
|
||||
t.end();
|
||||
});
|
||||
9
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/parse_modified.js
generated
vendored
Normal file
9
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/parse_modified.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('parse with modifier functions' , function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var argv = parse([ '-b', '123' ], { boolean: 'b' });
|
||||
t.deepEqual(argv, { b: true, _: [123] });
|
||||
});
|
||||
67
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/short.js
generated
vendored
Normal file
67
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/short.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('numeric short args', function (t) {
|
||||
t.plan(2);
|
||||
t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] });
|
||||
t.deepEqual(
|
||||
parse([ '-123', '456' ]),
|
||||
{ 1: true, 2: true, 3: 456, _: [] }
|
||||
);
|
||||
});
|
||||
|
||||
test('short', function (t) {
|
||||
t.deepEqual(
|
||||
parse([ '-b' ]),
|
||||
{ b : true, _ : [] },
|
||||
'short boolean'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ 'foo', 'bar', 'baz' ]),
|
||||
{ _ : [ 'foo', 'bar', 'baz' ] },
|
||||
'bare'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '-cats' ]),
|
||||
{ c : true, a : true, t : true, s : true, _ : [] },
|
||||
'group'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '-cats', 'meow' ]),
|
||||
{ c : true, a : true, t : true, s : 'meow', _ : [] },
|
||||
'short group next'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '-h', 'localhost' ]),
|
||||
{ h : 'localhost', _ : [] },
|
||||
'short capture'
|
||||
);
|
||||
t.deepEqual(
|
||||
parse([ '-h', 'localhost', '-p', '555' ]),
|
||||
{ h : 'localhost', p : 555, _ : [] },
|
||||
'short captures'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('mixed short bool and capture', function (t) {
|
||||
t.same(
|
||||
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
|
||||
{
|
||||
f : true, p : 555, h : 'localhost',
|
||||
_ : [ 'script.js' ]
|
||||
}
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('short and long', function (t) {
|
||||
t.deepEqual(
|
||||
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
|
||||
{
|
||||
f : true, p : 555, h : 'localhost',
|
||||
_ : [ 'script.js' ]
|
||||
}
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
15
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/stop_early.js
generated
vendored
Normal file
15
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/stop_early.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('stops parsing on the first non-option when stopEarly is set', function (t) {
|
||||
var argv = parse(['--aaa', 'bbb', 'ccc', '--ddd'], {
|
||||
stopEarly: true
|
||||
});
|
||||
|
||||
t.deepEqual(argv, {
|
||||
aaa: 'bbb',
|
||||
_: ['ccc', '--ddd']
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
102
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/unknown.js
generated
vendored
Normal file
102
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/unknown.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('boolean and alias is not unknown', function (t) {
|
||||
var unknown = [];
|
||||
function unknownFn(arg) {
|
||||
unknown.push(arg);
|
||||
return false;
|
||||
}
|
||||
var aliased = [ '-h', 'true', '--derp', 'true' ];
|
||||
var regular = [ '--herp', 'true', '-d', 'true' ];
|
||||
var opts = {
|
||||
alias: { h: 'herp' },
|
||||
boolean: 'h',
|
||||
unknown: unknownFn
|
||||
};
|
||||
var aliasedArgv = parse(aliased, opts);
|
||||
var propertyArgv = parse(regular, opts);
|
||||
|
||||
t.same(unknown, ['--derp', '-d']);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('flag boolean true any double hyphen argument is not unknown', function (t) {
|
||||
var unknown = [];
|
||||
function unknownFn(arg) {
|
||||
unknown.push(arg);
|
||||
return false;
|
||||
}
|
||||
var argv = parse(['--honk', '--tacos=good', 'cow', '-p', '55'], {
|
||||
boolean: true,
|
||||
unknown: unknownFn
|
||||
});
|
||||
t.same(unknown, ['--tacos=good', 'cow', '-p']);
|
||||
t.same(argv, {
|
||||
honk: true,
|
||||
_: []
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('string and alias is not unknown', function (t) {
|
||||
var unknown = [];
|
||||
function unknownFn(arg) {
|
||||
unknown.push(arg);
|
||||
return false;
|
||||
}
|
||||
var aliased = [ '-h', 'hello', '--derp', 'goodbye' ];
|
||||
var regular = [ '--herp', 'hello', '-d', 'moon' ];
|
||||
var opts = {
|
||||
alias: { h: 'herp' },
|
||||
string: 'h',
|
||||
unknown: unknownFn
|
||||
};
|
||||
var aliasedArgv = parse(aliased, opts);
|
||||
var propertyArgv = parse(regular, opts);
|
||||
|
||||
t.same(unknown, ['--derp', '-d']);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('default and alias is not unknown', function (t) {
|
||||
var unknown = [];
|
||||
function unknownFn(arg) {
|
||||
unknown.push(arg);
|
||||
return false;
|
||||
}
|
||||
var aliased = [ '-h', 'hello' ];
|
||||
var regular = [ '--herp', 'hello' ];
|
||||
var opts = {
|
||||
default: { 'h': 'bar' },
|
||||
alias: { 'h': 'herp' },
|
||||
unknown: unknownFn
|
||||
};
|
||||
var aliasedArgv = parse(aliased, opts);
|
||||
var propertyArgv = parse(regular, opts);
|
||||
|
||||
t.same(unknown, []);
|
||||
t.end();
|
||||
unknownFn(); // exercise fn for 100% coverage
|
||||
});
|
||||
|
||||
test('value following -- is not unknown', function (t) {
|
||||
var unknown = [];
|
||||
function unknownFn(arg) {
|
||||
unknown.push(arg);
|
||||
return false;
|
||||
}
|
||||
var aliased = [ '--bad', '--', 'good', 'arg' ];
|
||||
var opts = {
|
||||
'--': true,
|
||||
unknown: unknownFn
|
||||
};
|
||||
var argv = parse(aliased, opts);
|
||||
|
||||
t.same(unknown, ['--bad']);
|
||||
t.same(argv, {
|
||||
'--': ['good', 'arg'],
|
||||
'_': []
|
||||
})
|
||||
t.end();
|
||||
});
|
||||
8
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/whitespace.js
generated
vendored
Normal file
8
nodered/rootfs/data/node_modules/html-to-text/node_modules/minimist/test/whitespace.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('whitespace should be whitespace' , function (t) {
|
||||
t.plan(1);
|
||||
var x = parse([ '-x', '\t' ]).x;
|
||||
t.equal(x, '\t');
|
||||
});
|
||||
76
nodered/rootfs/data/node_modules/html-to-text/package.json
generated
vendored
Normal file
76
nodered/rootfs/data/node_modules/html-to-text/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "html-to-text@5.1.1",
|
||||
"_id": "html-to-text@5.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Bci6bD/JIfZSvG4s0gW/9mMKwBRoe/1RWLxUME/d6WUSZCdY7T60bssf/jFf7EYXRyqU4P5xdClVqiYU0/ypdA==",
|
||||
"_location": "/html-to-text",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "html-to-text@5.1.1",
|
||||
"name": "html-to-text",
|
||||
"escapedName": "html-to-text",
|
||||
"rawSpec": "5.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mailparser"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-5.1.1.tgz",
|
||||
"_shasum": "2d89db7bf34bc7bcb7d546b1b228991a16926e87",
|
||||
"_spec": "html-to-text@5.1.1",
|
||||
"_where": "/data/node_modules/mailparser",
|
||||
"author": {
|
||||
"name": "Malte Legenhausen",
|
||||
"email": "legenhausen@werk85.de"
|
||||
},
|
||||
"bin": {
|
||||
"html-to-text": "bin/cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/werk85/node-html-to-text/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"he": "^1.2.0",
|
||||
"htmlparser2": "^3.10.1",
|
||||
"lodash": "^4.17.11",
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Advanced html to plain text converter",
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^5.15.3",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^6.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/werk85/node-html-to-text",
|
||||
"keywords": [
|
||||
"html",
|
||||
"node",
|
||||
"text",
|
||||
"mail",
|
||||
"plain",
|
||||
"converter"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "html-to-text",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/werk85/node-html-to-text.git"
|
||||
},
|
||||
"scripts": {
|
||||
"example": "node ./example/html-to-text.js",
|
||||
"lint": "eslint .",
|
||||
"prepublish": "npm test",
|
||||
"test": "istanbul cover _mocha && eslint ."
|
||||
},
|
||||
"version": "5.1.1"
|
||||
}
|
||||
588
nodered/rootfs/data/node_modules/html-to-text/test/html-to-text.js
generated
vendored
Normal file
588
nodered/rootfs/data/node_modules/html-to-text/test/html-to-text.js
generated
vendored
Normal file
@@ -0,0 +1,588 @@
|
||||
/* eslint max-len: "off" */
|
||||
|
||||
var expect = require('chai').expect;
|
||||
var htmlToText = require('..');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
describe('html-to-text', function() {
|
||||
describe('.fromString()', function() {
|
||||
describe('wordwrap option', function() {
|
||||
|
||||
var longStr;
|
||||
|
||||
beforeEach(function() {
|
||||
longStr = '111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999';
|
||||
});
|
||||
|
||||
it('should wordwrap at 80 characters by default', function() {
|
||||
expect(htmlToText.fromString(longStr)).to.equal('111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888\n999999999');
|
||||
});
|
||||
|
||||
it('should wordwrap at given amount of characters when give a number', function() {
|
||||
|
||||
expect(htmlToText.fromString(longStr, { wordwrap: 20 })).to.equal('111111111 222222222\n333333333 444444444\n555555555 666666666\n777777777 888888888\n999999999');
|
||||
|
||||
expect(htmlToText.fromString(longStr, { wordwrap: 50 })).to.equal('111111111 222222222 333333333 444444444 555555555\n666666666 777777777 888888888 999999999');
|
||||
|
||||
expect(htmlToText.fromString(longStr, { wordwrap: 70 })).to.equal('111111111 222222222 333333333 444444444 555555555 666666666 777777777\n888888888 999999999');
|
||||
});
|
||||
|
||||
it('should not wordwrap when given null', function() {
|
||||
expect(htmlToText.fromString(longStr, { wordwrap: null })).to.equal(longStr);
|
||||
});
|
||||
|
||||
it('should not wordwrap when given false', function() {
|
||||
expect(htmlToText.fromString(longStr, { wordwrap: false })).to.equal(longStr);
|
||||
});
|
||||
|
||||
it('should not exceed the line width when processing embedded format tags', function() {
|
||||
var testString = '<p><strong>This text isn\'t counted</strong> when calculating where to break a string for 80 character line lengths.</p>';
|
||||
expect(htmlToText.fromString(testString, {} )).to.equal('This text isn\'t counted when calculating where to break a string for 80\ncharacter line lengths.');
|
||||
});
|
||||
|
||||
it('should work with a long string containing line feeds', function() {
|
||||
var testString = '<p>If a word with a line feed exists over the line feed boundary then\nyou\nmust\nrespect it.</p>';
|
||||
expect(htmlToText.fromString(testString, {} )).to.equal('If a word with a line feed exists over the line feed boundary then you must\nrespect it.');
|
||||
});
|
||||
|
||||
it('should not wrongly truncate lines when processing embedded format tags', function() {
|
||||
var testString = '<p><strong>This text isn\'t counted</strong> when calculating where to break a string for 80 character line lengths. However it can affect where the next line breaks and this could lead to having an early line break</p>';
|
||||
expect(htmlToText.fromString(testString, {} )).to.equal('This text isn\'t counted when calculating where to break a string for 80\ncharacter line lengths. However it can affect where the next line breaks and\nthis could lead to having an early line break');
|
||||
});
|
||||
|
||||
it('should not exceed the line width when processing anchor tags', function() {
|
||||
var testString = "<p>We appreciate your business. And we hope you'll check out our <a href=\"http://example.com/\">new products</a>!</p>";
|
||||
expect(htmlToText.fromString(testString, {} )).to.equal('We appreciate your business. And we hope you\'ll check out our new products\n[http://example.com/]!');
|
||||
});
|
||||
|
||||
it('should honour line feeds from a long word across the wrap, where the line feed is before the wrap', function() {
|
||||
var testString = '<p>This string is meant to test if a string is split properly across a\nnewlineandlongword with following text.</p>';
|
||||
expect(htmlToText.fromString(testString, {} ))
|
||||
.to.equal('This string is meant to test if a string is split properly across a\nnewlineandlongword with following text.');
|
||||
});
|
||||
|
||||
it('should remove line feeds from a long word across the wrap, where the line feed is after the wrap', function() {
|
||||
var testString = '<p>This string is meant to test if a string is split properly across anewlineandlong\nword with following text.</p>';
|
||||
expect(htmlToText.fromString(testString, {} ))
|
||||
.to.equal('This string is meant to test if a string is split properly across\nanewlineandlong word with following text.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('preserveNewlines option', function() {
|
||||
|
||||
var newlineStr;
|
||||
|
||||
beforeEach(function() {
|
||||
newlineStr = '<p\n>One\nTwo\nThree</p>';
|
||||
});
|
||||
|
||||
it('should not preserve newlines by default', function() {
|
||||
expect(htmlToText.fromString(newlineStr)).to.not.contain('\n');
|
||||
});
|
||||
|
||||
it('should preserve newlines when provided with a truthy value', function() {
|
||||
expect(htmlToText.fromString(newlineStr, { preserveNewlines: true })).to.contain('\n');
|
||||
});
|
||||
|
||||
it('should not preserve newlines in the tags themselves', function() {
|
||||
var output_text = htmlToText.fromString(newlineStr, { preserveNewlines: true });
|
||||
expect(output_text.slice(0,1)).to.equal("O");
|
||||
});
|
||||
|
||||
it('should preserve line feeds in a long wrapping string containing line feeds', function() {
|
||||
var testString = '<p>If a word with a line feed exists over the line feed boundary then\nyou\nmust\nrespect it.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true } ))
|
||||
.to.equal('If a word with a line feed exists over the line feed boundary then\nyou\nmust\nrespect it.');
|
||||
});
|
||||
|
||||
it('should preserve line feeds in a long string containing line feeds across the wrap', function() {
|
||||
var testString = '<p>If a word with a line feed exists over the line feed boundary then\nyou must respect it.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true } ))
|
||||
.to.equal('If a word with a line feed exists over the line feed boundary then\nyou must respect it.');
|
||||
});
|
||||
|
||||
it('should preserve line feeds in a long string containing line feeds across the wrap with a line feed before 80 chars', function() {
|
||||
var testString = '<p>This string is meant to test if a string is split properly across a\nnewlineandlongword with following text.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true } ))
|
||||
.to.equal('This string is meant to test if a string is split properly across a\nnewlineandlongword with following text.');
|
||||
});
|
||||
|
||||
it('should preserve line feeds in a long string containing line feeds across the wrap with a line feed after 80 chars', function() {
|
||||
var testString = '<p>This string is meant to test if a string is split properly across anewlineandlong\nword with following text.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true } ))
|
||||
.to.equal('This string is meant to test if a string is split properly across\nanewlineandlong\nword with following text.');
|
||||
});
|
||||
|
||||
it('should split long lines', function() {
|
||||
var testString = '<p>If a word with a line feed exists over the line feed boundary then you must respect it.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true } ))
|
||||
.to.equal('If a word with a line feed exists over the line feed boundary then you must\nrespect it.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('single line paragraph option', function() {
|
||||
|
||||
var paragraphsString;
|
||||
|
||||
beforeEach(function() {
|
||||
paragraphsString = '<p>First</p><p>Second</p>';
|
||||
});
|
||||
|
||||
it('should not use single new line when given null', function() {
|
||||
expect(htmlToText.fromString(paragraphsString, { singleNewLineParagraphs: null } )).to.equal('First\n\nSecond');
|
||||
});
|
||||
|
||||
it('should not use single new line when given false', function() {
|
||||
expect(htmlToText.fromString(paragraphsString, { singleNewLineParagraphs: false } )).to.equal('First\n\nSecond');
|
||||
});
|
||||
|
||||
it('should use single new line when given true', function() {
|
||||
expect(htmlToText.fromString(paragraphsString, { singleNewLineParagraphs: true } )).to.equal('First\nSecond');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('tables', function () {
|
||||
it('does not process tables with uppercase tags / does not process tables with center tag', function () {
|
||||
var html = 'Good morning Jacob, \
|
||||
<TABLE> \
|
||||
<CENTER> \
|
||||
<TBODY> \
|
||||
<TR> \
|
||||
<TD>Lorem ipsum dolor sit amet.</TD> \
|
||||
</TR> \
|
||||
</CENTER> \
|
||||
</TBODY> \
|
||||
</TABLE> \
|
||||
';
|
||||
var resultExpected = 'Good morning Jacob, Lorem ipsum dolor sit amet.';
|
||||
var result = htmlToText.fromString(html, { tables: true });
|
||||
expect(result).to.equal(resultExpected);
|
||||
});
|
||||
|
||||
it('does handle non-integer colspan on td element gracefully', function () {
|
||||
var html = 'Good morning Jacob, \
|
||||
<TABLE> \
|
||||
<CENTER> \
|
||||
<TBODY> \
|
||||
<TR> \
|
||||
<TD colspan="abc">Lorem ipsum dolor sit amet.</TD> \
|
||||
</TR> \
|
||||
</CENTER> \
|
||||
</TBODY> \
|
||||
</TABLE> \
|
||||
';
|
||||
var resultExpected = 'Good morning Jacob, Lorem ipsum dolor sit amet.';
|
||||
var result = htmlToText.fromString(html, { tables: true });
|
||||
expect(result).to.equal(resultExpected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('a', function () {
|
||||
it('should decode html attribute entities from href', function () {
|
||||
var result = htmlToText.fromString('<a href="/foo?a=b">test</a>');
|
||||
expect(result).to.equal('test [/foo?a=b]');
|
||||
});
|
||||
|
||||
it('should strip mailto: from email links', function () {
|
||||
var result = htmlToText.fromString('<a href="mailto:foo@example.com">email me</a>');
|
||||
expect(result).to.equal('email me [foo@example.com]');
|
||||
});
|
||||
|
||||
it('should return link with brackets', function () {
|
||||
var result = htmlToText.fromString('<a href="http://my.link">test</a>');
|
||||
expect(result).to.equal('test [http://my.link]');
|
||||
});
|
||||
|
||||
it('should return link without brackets', function () {
|
||||
var result = htmlToText.fromString('<a href="http://my.link">test</a>', {
|
||||
noLinkBrackets: true
|
||||
});
|
||||
expect(result).to.equal('test http://my.link');
|
||||
});
|
||||
|
||||
it('should not return link for anchor if noAnchorUrl is set to true', function () {
|
||||
var result = htmlToText.fromString('<a href="#link">test</a>', {
|
||||
noAnchorUrl: true
|
||||
});
|
||||
expect(result).to.equal('test');
|
||||
});
|
||||
|
||||
it('should return link for anchor if noAnchorUrl is set to false', function () {
|
||||
var result = htmlToText.fromString('<a href="#link">test</a>', {
|
||||
noAnchorUrl: false
|
||||
});
|
||||
expect(result).to.equal('test [#link]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('lists', function() {
|
||||
describe('ul', function() {
|
||||
it('should handle empty unordered lists', function() {
|
||||
var testString = '<ul></ul>';
|
||||
expect(htmlToText.fromString(testString)).to.equal('');
|
||||
});
|
||||
|
||||
it('should handle an unordered list with multiple elements', function() {
|
||||
var testString = '<ul><li>foo</li><li>bar</li></ul>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' * foo\n * bar');
|
||||
});
|
||||
|
||||
it('should handle an unordered list prefix option', function() {
|
||||
var testString = '<ul><li>foo</li><li>bar</li></ul>';
|
||||
var options = {unorderedListItemPrefix: ' test '};
|
||||
expect(htmlToText.fromString(testString, options)).to.equal(' test foo\n test bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol', function() {
|
||||
it('should handle empty ordered lists', function() {
|
||||
var testString = '<ol></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal('');
|
||||
});
|
||||
|
||||
it('should handle an ordered list with multiple elements', function() {
|
||||
var testString = '<ol><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' 1. foo\n 2. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list type="1" attribute', function() {
|
||||
var testString = '<ol type="1"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' 1. foo\n 2. bar');
|
||||
});
|
||||
|
||||
it('should fallback to type="!" behavior if type attribute is invalid', function() {
|
||||
var testString = '<ol type="1"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' 1. foo\n 2. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list type="a" attribute', function() {
|
||||
var testString = '<ol type="a"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' a. foo\n b. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list type="A" attribute', function() {
|
||||
var testString = '<ol type="A"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' A. foo\n B. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list type="i" attribute by falling back to type="1"', function() {
|
||||
var testString = '<ol type="i"><li>foo</li><li>bar</li></ol>';
|
||||
// TODO Implement lowercase roman numerals
|
||||
// expect(htmlToText.fromString(testString)).to.equal('i. foo\nii. bar');
|
||||
expect(htmlToText.fromString(testString)).to.equal(' 1. foo\n 2. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list type="I" attribute by falling back to type="1"', function() {
|
||||
var testString = '<ol type="I"><li>foo</li><li>bar</li></ol>';
|
||||
// TODO Implement uppercase roman numerals
|
||||
// expect(htmlToText.fromString(testString)).to.equal('I. foo\nII. bar');
|
||||
expect(htmlToText.fromString(testString)).to.equal(' 1. foo\n 2. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list start attribute', function() {
|
||||
var testString = '<ol start="2"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal(' 2. foo\n 3. bar');
|
||||
});
|
||||
|
||||
/*
|
||||
* Currently failing tests for continuing to fill out the specification
|
||||
* Spec: https://html.spec.whatwg.org/multipage/semantics.html#the-ol-element
|
||||
*
|
||||
it('should support the ordered list type="a" attribute past 26 characters', function() {
|
||||
var testString = '<ol start="26" type="a"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal('z. foo\naa. bar');
|
||||
});
|
||||
|
||||
it('should support the ordered list type="A" attribute past 26 characters', function() {
|
||||
var testString = '<ol start="26" type="A"><li>foo</li><li>bar</li></ol>';
|
||||
expect(htmlToText.fromString(testString)).to.equal('Z. foo\nAA. bar');
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
it('doesnt wrap li if wordwrap isnt', function () {
|
||||
var html = 'Good morning Jacob, \
|
||||
<p>Lorem ipsum dolor sit amet</p> \
|
||||
<p><strong>Lorem ipsum dolor sit amet.</strong></p> \
|
||||
<ul> \
|
||||
<li>run in the park <span style="color:#888888;">(in progress)</span></li> \
|
||||
</ul> \
|
||||
';
|
||||
var resultExpected = 'Good morning Jacob, Lorem ipsum dolor sit amet\n\nLorem ipsum dolor sit amet.\n\n * run in the park (in progress)';
|
||||
var result = htmlToText.fromString(html, { wordwrap: false });
|
||||
expect(result).to.equal(resultExpected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('entities', function () {
|
||||
it('does not insert null bytes', function () {
|
||||
var html = '<a href="some-url?a=b&b=c">Testing & Done</a>';
|
||||
|
||||
var result = htmlToText.fromString(html);
|
||||
expect(result).to.equal('Testing & Done [some-url?a=b&b=c]');
|
||||
});
|
||||
|
||||
it('should replace entities inside `alt` attributes of images', function () {
|
||||
var html = '<img src="test.png" alt=""Awesome"">';
|
||||
|
||||
var result = htmlToText.fromString(html);
|
||||
expect(result).to.equal('"Awesome" [test.png]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('unicode support', function () {
|
||||
it('should decode 😂 to 😂', function () {
|
||||
var result = htmlToText.fromString('😂');
|
||||
expect(result).to.equal('😂');
|
||||
});
|
||||
});
|
||||
|
||||
describe('disable uppercaseHeadings', function () {
|
||||
[1, 2, 3, 4, 5, 6].forEach(function (i) {
|
||||
it('should return h' + i + ' in lowercase', function () {
|
||||
var result = htmlToText.fromString('<h' + i + '>test</h' + i + '>', {
|
||||
uppercaseHeadings: false
|
||||
});
|
||||
expect(result).to.equal('test');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('custom formatting', function () {
|
||||
it('should allow to pass custom formatting functions', function () {
|
||||
var result = htmlToText.fromString('<h1>TeSt</h1>', {
|
||||
format: {
|
||||
heading: function (elem, fn, options) {
|
||||
var h = fn(elem.children, options);
|
||||
return '====\n' + h.toLowerCase() + '\n====';
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(result).to.equal('====\ntest\n====');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Base element', function () {
|
||||
it('should retrieve and convert the entire document under `body` by default', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
var txtFile = fs.readFileSync(path.join(__dirname, 'test.txt'), 'utf8');
|
||||
|
||||
var options = {
|
||||
tables: ['#invoice', '.address']
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(txtFile);
|
||||
});
|
||||
|
||||
it('should only retrieve and convert content under the specified base element if found', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
var txtFile = fs.readFileSync(path.join(__dirname, 'test-address.txt'), 'utf8');
|
||||
|
||||
var options = {
|
||||
tables: ['.address'],
|
||||
baseElement: 'table.address'
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(txtFile);
|
||||
});
|
||||
|
||||
it('should retrieve and convert content under multiple base elements', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
var txtFile = fs.readFileSync(path.join(__dirname, 'test-address-dup.txt'), 'utf8');
|
||||
|
||||
var options = {
|
||||
tables: ['.address'],
|
||||
baseElement: ['table.address', 'table.address']
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(txtFile);
|
||||
});
|
||||
|
||||
it('should retrieve and convert content under multiple base elements in any order', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
var txtFile = fs.readFileSync(path.join(__dirname, 'test-any-order.txt'), 'utf8');
|
||||
|
||||
var options = {
|
||||
tables: ['.address'],
|
||||
baseElement: ['table.address', 'p.normal-space', 'table.address']
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(txtFile);
|
||||
});
|
||||
|
||||
it('should process the first base element found when multiple exist', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
var txtFile = fs.readFileSync(path.join(__dirname, 'test-first-element.txt'), 'utf8');
|
||||
|
||||
var options = {
|
||||
tables: ['.address'],
|
||||
baseElement: 'p.normal-space'
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(txtFile);
|
||||
});
|
||||
|
||||
it('should retrieve and convert the entire document by default if no base element is found', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
var txtFile = fs.readFileSync(path.join(__dirname, 'test.txt'), 'utf8');
|
||||
|
||||
var options = {
|
||||
tables: ['#invoice', '.address'],
|
||||
baseElement: 'table.notthere'
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(txtFile);
|
||||
});
|
||||
|
||||
it('should return null if the base element isn\'t found and we\'re not returning the DOM by default', function() {
|
||||
var htmlFile = fs.readFileSync(path.join(__dirname, 'test.html'), 'utf8');
|
||||
|
||||
var expectedTxt = '';
|
||||
var options = {
|
||||
tables: ['#invoice', '.address'],
|
||||
baseElement: 'table.notthere',
|
||||
returnDomByDefault: false
|
||||
};
|
||||
var text = htmlToText.fromString(htmlFile, options);
|
||||
expect(text).to.equal(expectedTxt);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Long words', function() {
|
||||
it('should split long words if forceWrapOnLimit is set, existing linefeeds converted to space', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/'], forceWrapOnLimit: true }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlo\nng word_with_following_text.');
|
||||
});
|
||||
|
||||
it('should not wrap a string if longWordSplit is not set', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlongword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, {} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlongword_with_following_text.');
|
||||
});
|
||||
|
||||
it('should not wrap a string if not wrapCharacters are found and forceWrapOnLimit is not set', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.');
|
||||
});
|
||||
|
||||
it('should not wrap a string if no wrapCharacters are set and forceWrapOnLimit is not set', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: [], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.');
|
||||
});
|
||||
|
||||
it('should wrap on the last instance of a wrap character before the wordwrap limit.', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/', '_'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_\nanewlineandlong word_with_following_text.');
|
||||
});
|
||||
|
||||
it('should wrap on the last instance of a wrap character before the wordwrap limit. Content of wrapCharacters shouldn\'t matter.', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/','-', '_'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_\nanewlineandlong word_with_following_text.');
|
||||
});
|
||||
|
||||
it('should wrap on the last instance of a wrap character before the wordwrap limit. Order of wrapCharacters shouldn\'t matter.', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['_', '/'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_\nanewlineandlong word_with_following_text.');
|
||||
});
|
||||
|
||||
it('should wrap on the last instance of a wrap character before the wordwrap limit. Should preference wrapCharacters in order', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split-properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['-', '_', '/'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split-\nproperly_across_anewlineandlong word_with_following_text.');
|
||||
});
|
||||
|
||||
it('should not wrap a string that is too short', function() {
|
||||
var testString = '<p>https://github.com/werk85/node-html-to-text/blob/master/lib/html-to-text.js</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/', '-'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('https://github.com/werk85/node-html-to-text/blob/master/lib/html-to-text.js');
|
||||
});
|
||||
|
||||
it('should wrap a url string using \'/\'', function() {
|
||||
var testString = '<p>https://github.com/AndrewFinlay/node-html-to-text/commit/64836a5bd97294a672b24c26cb8a3ccdace41001</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/', '-'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('https://github.com/AndrewFinlay/node-html-to-text/commit/\n64836a5bd97294a672b24c26cb8a3ccdace41001');
|
||||
});
|
||||
|
||||
it('should wrap very long url strings using \'/\'', function() {
|
||||
var testString = '<p>https://github.com/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/html-to-text.js</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: ['/', '-'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('https://github.com/werk85/node-html-to-text/blob/master/lib/werk85/\nnode-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/\nwerk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/\nlib/html-to-text.js');
|
||||
});
|
||||
|
||||
it('should wrap very long url strings using limit', function() {
|
||||
var testString = '<p>https://github.com/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/html-to-text.js</p>';
|
||||
expect(htmlToText.fromString(testString, { longWordSplit: { wrapCharacters: [], forceWrapOnLimit: true }} ))
|
||||
.to.equal('https://github.com/werk85/node-html-to-text/blob/master/lib/werk85/node-html-to-\ntext/blob/master/lib/werk85/node-html-to-text/blob/master/lib/werk85/node-html-t\no-text/blob/master/lib/werk85/node-html-to-text/blob/master/lib/html-to-text.js');
|
||||
});
|
||||
|
||||
it('should honour preserveNewlines and split long words', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true, longWordSplit: { wrapCharacters: ['/', '_'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_\nanewlineandlong\nword_with_following_text.');
|
||||
});
|
||||
|
||||
it('should not put in extra linefeeds if the end of the untouched long string coincides with a preserved line feed', function() {
|
||||
var testString = '<p>_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.</p>';
|
||||
expect(htmlToText.fromString(testString, { preserveNewlines: true } ))
|
||||
.to.equal('_This_string_is_meant_to_test_if_a_string_is_split_properly_across_anewlineandlong\nword_with_following_text.');
|
||||
});
|
||||
|
||||
it('should split long strings buried in links and hide the href', function() {
|
||||
var testString = '<a href="http://images.fb.com/2015/12/21/ivete-sangalo-launches-360-music-video-on-facebook/">http://images.fb.com/2015/12/21/ivete-sangalo-launches-360-music-video-on-facebook/</a>';
|
||||
expect(htmlToText.fromString(testString, { hideLinkHrefIfSameAsText: true, longWordSplit: { wrapCharacters: ['/', '_'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('http://images.fb.com/2015/12/21/\nivete-sangalo-launches-360-music-video-on-facebook/');
|
||||
});
|
||||
|
||||
it('should split long strings buried in links and show the href', function() {
|
||||
var testString = '<a href="http://images.fb.com/2015/12/21/ivete-sangalo-launches-360-music-video-on-facebook/">http://images.fb.com/2015/12/21/ivete-sangalo-launches-360-music-video-on-facebook/</a>';
|
||||
expect(htmlToText.fromString(testString, { hideLinkHrefIfSameAsText: false, longWordSplit: { wrapCharacters: ['/', '_'], forceWrapOnLimit: false }} ))
|
||||
.to.equal('http://images.fb.com/2015/12/21/\nivete-sangalo-launches-360-music-video-on-facebook/\n[http://images.fb.com/2015/12/21/\nivete-sangalo-launches-360-music-video-on-facebook/]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('whitespace', function() {
|
||||
it('should not be ignored inside a whitespace-only node', function() {
|
||||
var testString = 'foo<span> </span>bar';
|
||||
expect(htmlToText.fromString(testString)).to.equal('foo bar');
|
||||
});
|
||||
|
||||
it('should not add additional whitespace after <sup>', function() {
|
||||
var testString = '<p>This text contains <sup>superscript</sup> text.</p>';
|
||||
var options = { preserveNewlines: true };
|
||||
|
||||
expect(htmlToText.fromString(testString, options)).to.equal('This text contains superscript text.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('wbr', function() {
|
||||
it('should handle a large number of wbr tags w/o stack overflow', function() {
|
||||
var testString = "<!DOCTYPE html><html><head></head><body>\n";
|
||||
var expectedResult = "";
|
||||
for (var i = 0; i < 1000; i++){
|
||||
if (i !== 0 && i % 80 === 0) {
|
||||
expectedResult += "\n";
|
||||
}
|
||||
expectedResult += "n";
|
||||
testString += "<wbr>n";
|
||||
}
|
||||
testString += "</body></html>";
|
||||
expect(htmlToText.fromString(testString)).to.equal(expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('blockquote', function() {
|
||||
it('should handle format blockquote', function() {
|
||||
var testString = 'foo<blockquote>test</blockquote>bar';
|
||||
var expectedResult = 'foo> test\nbar';
|
||||
expect(htmlToText.fromString(testString)).to.equal(expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
11
nodered/rootfs/data/node_modules/html-to-text/test/test-address-dup.txt
generated
vendored
Normal file
11
nodered/rootfs/data/node_modules/html-to-text/test/test-address-dup.txt
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
5
nodered/rootfs/data/node_modules/html-to-text/test/test-address.txt
generated
vendored
Normal file
5
nodered/rootfs/data/node_modules/html-to-text/test/test-address.txt
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
18
nodered/rootfs/data/node_modules/html-to-text/test/test-any-order.txt
generated
vendored
Normal file
18
nodered/rootfs/data/node_modules/html-to-text/test/test-any-order.txt
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
|
||||
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
||||
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
|
||||
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
||||
takimata sanctus est Lorem ipsum dolor sit amet. Github [www.github.com]
|
||||
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
98
nodered/rootfs/data/node_modules/html-to-text/test/test-cli.js
generated
vendored
Normal file
98
nodered/rootfs/data/node_modules/html-to-text/test/test-cli.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
var expect = require('chai').expect;
|
||||
var fs = require('fs');
|
||||
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
function runWithInputAndExpect(input, args, expectedOutput, done) {
|
||||
exec('echo "' + input.replace(/"/g, '\\"') + '" | node bin/cli.js ' + args, function callback(error, stdout, stderr) {
|
||||
expect(error).to.be.a('null');
|
||||
expect(stderr).to.equal('');
|
||||
expect(stdout).to.equal(expectedOutput + '\n');
|
||||
done(error);
|
||||
});
|
||||
}
|
||||
|
||||
describe('cli arguments', function() {
|
||||
it('should output nothing with empty input', function(done) {
|
||||
runWithInputAndExpect('', '', '', done);
|
||||
});
|
||||
|
||||
it('should not ignore images by default', function (done) {
|
||||
runWithInputAndExpect(
|
||||
'Hello <img alt="alt text" src="http://my.img/here.jpg">!',
|
||||
'',
|
||||
'Hello alt text [http://my.img/here.jpg]!',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should ignore images with --ignore-image=true', function (done) {
|
||||
runWithInputAndExpect(
|
||||
'Hello <img alt="alt text" src="http://my.img/here.jpg">!',
|
||||
'--ignore-image=true',
|
||||
'Hello !',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should not ignore href by default', function (done) {
|
||||
runWithInputAndExpect(
|
||||
'<a href="http://my.link">test</a>',
|
||||
'',
|
||||
'test [http://my.link]',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should ignore href with --ignore-href=true', function (done) {
|
||||
runWithInputAndExpect(
|
||||
'<a href="http://my.link">test</a>',
|
||||
'--ignore-href=true',
|
||||
'test',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should wordwrap at 80 characters by default', function (done) {
|
||||
runWithInputAndExpect(
|
||||
' 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789',
|
||||
'',
|
||||
' 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789\n123456789',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should wordwrap at 40 with --wordwrap=40', function (done) {
|
||||
runWithInputAndExpect(
|
||||
' 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789',
|
||||
'--wordwrap=40',
|
||||
' 123456789 123456789 123456789 123456789\n123456789 123456789 123456789 123456789\n123456789',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should return link with brackets by default', function (done) {
|
||||
runWithInputAndExpect(
|
||||
'<a href="http://my.link">test</a>',
|
||||
'',
|
||||
'test [http://my.link]',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should return link without brackets with --noLinkBrackets=true', function (done) {
|
||||
runWithInputAndExpect(
|
||||
'<a href="http://my.link">test</a>',
|
||||
'--noLinkBrackets=true',
|
||||
'test http://my.link',
|
||||
done);
|
||||
});
|
||||
|
||||
it('should support --tables definitions with commas', function(done) {
|
||||
var expectedTxt = fs.readFileSync('test/test.txt', 'utf8');
|
||||
|
||||
function runWithArgs(args, callback) {
|
||||
exec('cat test/test.html | node bin/cli.js ' + args, callback);
|
||||
}
|
||||
|
||||
runWithArgs('--tables=#invoice,.address', function callback(error, stdout, stderr) {
|
||||
expect(error).to.be.a('null');
|
||||
expect(stderr).to.equal('');
|
||||
expect(stdout).to.equal(expectedTxt + '\n');
|
||||
done(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
6
nodered/rootfs/data/node_modules/html-to-text/test/test-first-element.txt
generated
vendored
Normal file
6
nodered/rootfs/data/node_modules/html-to-text/test/test-first-element.txt
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
|
||||
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
||||
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
|
||||
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
||||
takimata sanctus est Lorem ipsum dolor sit amet. Github [www.github.com]
|
||||
136
nodered/rootfs/data/node_modules/html-to-text/test/test.html
generated
vendored
Normal file
136
nodered/rootfs/data/node_modules/html-to-text/test/test.html
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
h2 {
|
||||
font-size:18px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
alert('Hallo Welt');
|
||||
</script>
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<h2>Paragraphs</h2>
|
||||
<p class="normal-space">At vero eos et accu<strong>sam</strong> et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <a href="www.github.com">Github</a>
|
||||
</p>
|
||||
<p class="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
</p>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Pretty printed table</h2>
|
||||
<table id="invoice">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Article</th>
|
||||
<th>Price</th>
|
||||
<th>Taxes</th>
|
||||
<th>Amount</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Product 1<br />
|
||||
<span style="font-size:0.8em">Contains: 1x Product 1</span>
|
||||
</p>
|
||||
</td>
|
||||
<td align="right" valign="top">6,99€</td>
|
||||
<td align="right" valign="top">7%</td>
|
||||
<td align="right" valign="top">1</td>
|
||||
<td align="right" valign="top">6,99€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Shipment costs</td>
|
||||
<td align="right">3,25€</td>
|
||||
<td align="right">7%</td>
|
||||
<td align="right">1</td>
|
||||
<td align="right">3,25€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td colspan="3">to pay: 10,24€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3">Taxes 7%: 0,72€</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr/>
|
||||
<h2>Lists</h2>
|
||||
<ul>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
</ul>
|
||||
<ol>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
<li>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<hr />
|
||||
<h2>Column Layout with tables</h2>
|
||||
<table class="address">
|
||||
<tr>
|
||||
<th align="left">Invoice Address</th>
|
||||
<th align="left">Shipment Address</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
<p>
|
||||
Mr.<br/>
|
||||
John Doe<br/>
|
||||
Featherstone Street 49<br/>
|
||||
28199 Bremen<br/>
|
||||
</p>
|
||||
</td>
|
||||
<td align="left">
|
||||
<p>
|
||||
Mr.<br/>
|
||||
John Doe<br/>
|
||||
Featherstone Street 49<br/>
|
||||
28199 Bremen<br/>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a name="#anchor"></a>
|
||||
<hr/>
|
||||
<h2>Mailto formating</h2>
|
||||
<p class="normal-space small">
|
||||
Some Company<br />
|
||||
Some Street 42<br />
|
||||
Somewhere<br />
|
||||
E-Mail: <a href="mailto:test@example.com">Click here</a>
|
||||
</p>
|
||||
<p>We appreciate your business. And we hope you'll check out our <a href="http://example.com/">new products</a>!</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
61
nodered/rootfs/data/node_modules/html-to-text/test/test.txt
generated
vendored
Normal file
61
nodered/rootfs/data/node_modules/html-to-text/test/test.txt
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
PARAGRAPHS
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
|
||||
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
||||
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
|
||||
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
||||
takimata sanctus est Lorem ipsum dolor sit amet. Github [www.github.com]
|
||||
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
|
||||
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
|
||||
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
|
||||
et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
||||
takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
PRETTY PRINTED TABLE
|
||||
ARTICLE PRICE TAXES AMOUNT TOTAL
|
||||
Product 1 6,99€ 7% 1 6,99€
|
||||
Contains: 1x Product 1
|
||||
Shipment costs 3,25€ 7% 1 3,25€
|
||||
to pay: 10,24€
|
||||
Taxes 7%: 0,72€
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
LISTS
|
||||
* At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
* At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
1. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
2. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
|
||||
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
COLUMN LAYOUT WITH TABLES
|
||||
INVOICE ADDRESS SHIPMENT ADDRESS
|
||||
Mr. Mr.
|
||||
John Doe John Doe
|
||||
Featherstone Street 49 Featherstone Street 49
|
||||
28199 Bremen 28199 Bremen
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
MAILTO FORMATING
|
||||
Some Company
|
||||
Some Street 42
|
||||
Somewhere
|
||||
E-Mail: Click here [test@example.com]
|
||||
|
||||
We appreciate your business. And we hope you'll check out our new products
|
||||
[http://example.com/]!
|
||||
Reference in New Issue
Block a user