From 4e525a991f1a41881648bb90986246648457addd Mon Sep 17 00:00:00 2001 From: Eugene Kuzmenko Date: Fri, 4 Mar 2016 12:31:24 +0200 Subject: [PATCH] [removed] transformer support from the `Markup` class; updated the library definition file and the project dependencies --- docs/Markup.html | 79 ++---------------- docs/Markup.js.html | 39 +-------- docs/global.html | 164 -------------------------------------- docs/quicksearch.html | 2 +- docs/typedef.js.html | 12 --- interfaces/webcompiler.js | 3 +- lib/Markup.js | 81 +++++-------------- package.json | 10 +-- src/Markup.js | 39 +-------- src/typedef.js | 12 --- test/Markup.spec.js | 48 +---------- 11 files changed, 41 insertions(+), 448 deletions(-) diff --git a/docs/Markup.html b/docs/Markup.html index 36139b3..004cd9b 100644 --- a/docs/Markup.html +++ b/docs/Markup.html @@ -89,7 +89,7 @@


-

new Markup(transformers)

+

new Markup()

@@ -99,7 +99,6 @@

new Markup(tran

Allows to easily and efficiently convert text from Markdown to HTML and from HTML to a collection of React Elements that can be used directly in a JSX expression.

-

Whenever an HTML string is involved, runs it through an array of Transformer functions.

@@ -109,68 +108,6 @@

new Markup(tran -

Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
transformers - - -Transformer - - - - - - - - - - - <repeatable>
- -

transformers to initialize with

- -
@@ -208,7 +145,7 @@
Parameters:
@@ -386,7 +323,7 @@
Parameters:
@@ -576,7 +513,7 @@
Parameters:
@@ -766,7 +703,7 @@
Parameters:
@@ -954,7 +891,7 @@
Parameters:
@@ -1142,7 +1079,7 @@
Parameters:
@@ -1330,7 +1267,7 @@
Parameters:
diff --git a/docs/Markup.js.html b/docs/Markup.js.html index ad7c7f9..043e570 100644 --- a/docs/Markup.js.html +++ b/docs/Markup.js.html @@ -77,7 +77,7 @@

Source: Markup.js

/* @flow */
 
-import type {CheerioNode, CheerioElement, Transformer} from './typedef';
+import type {CheerioNode, CheerioElement} from './typedef';
 import {load} from 'cheerio';
 import {createElement} from 'react';
 import marked from 'marked';
@@ -85,7 +85,6 @@ 

Source: Markup.js

import map from 'lodash/map'; import transform from 'lodash/transform'; import has from 'lodash/has'; -import reduce from 'lodash/reduce'; import flattenDeep from 'lodash/flattenDeep'; import isString from 'lodash/isString'; import trim from 'lodash/trim'; @@ -113,31 +112,13 @@

Source: Markup.js

* Allows to easily and efficiently convert text from Markdown to HTML and from HTML to a collection of React Elements * that can be used directly in a JSX expression. * - * Whenever an HTML string is involved, runs it through an array of Transformer functions. - * * @class Markup - * @param {...Transformer} transformers - transformers to initialize with * @example * import {Markup} from 'webcompiler'; * * const mark = new Markup(); */ export class Markup { - /** - * an array of Transformer functions - * - * @member {Array<Transformer>} transformers - * @memberof Markup - * @private - * @instance - */ - transformers: Array<Transformer>; - - /** @constructs */ - constructor(...transformers: Array<Transformer>) { - this.transformers = transformers; - } - /** * Convert the CSS style key to a JSX style key * @@ -364,20 +345,6 @@

Source: Markup.js

return Markup.childrenToJSX(lines.toArray()); } - /** - * Runs the html string through an array of Transformer functions - * - * @memberof Markup - * @instance - * @private - * @method transform - * @param {string} html - an arbitrary HTML string - * @return {string} a transformed string - */ - transform(html: string): string { - return reduce(this.transformers, (result, transformer) => transformer(result), html); - } - /** * Converts an arbitrary HTML string to an array of React Elements * @@ -391,7 +358,7 @@

Source: Markup.js

*/ htmlToJSX(html: string = ''): Array<any> { html = trim(html); - return html ? Markup.childrenToJSX(load(this.transform(html)).root().toArray()[0].children) : []; + return html ? Markup.childrenToJSX(load(html).root().toArray()[0].children) : []; } /** @@ -407,7 +374,7 @@

Source: Markup.js

*/ markdownToHTML(markdown: string = ''): string { markdown = trim(markdown); - return markdown ? trim(this.transform(Markup.markdownToUnwrappedHTML(markdown))) : ''; + return markdown ? Markup.markdownToUnwrappedHTML(markdown) : ''; } /** diff --git a/docs/global.html b/docs/global.html index 4559ce0..e2a32fd 100644 --- a/docs/global.html +++ b/docs/global.html @@ -2907,170 +2907,6 @@
Parameters:
- - - - -
-
-

Transformer(input)

- - -
-
- - -
-

Must be a pure function, always return the same value given the same input, must be side-effect free and not depend -on other replacers executing before it.

-

If provided with a result of its own previous execution, must return it unchanged.

-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - -string - - - - -

a transformed string

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- -
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - -
-

transformed output

-
- - - -
-
- Type -
-
- -string - - - -
-
- - - - -
diff --git a/docs/quicksearch.html b/docs/quicksearch.html index acd62bb..14ca31e 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@