Comparing version 6.0.1 to 7.0.0
14
index.js
@@ -1,6 +0,6 @@ | ||
var htmlparser = require('htmlparser2'); | ||
var Core = require('./lib/core'); | ||
var State = require('./lib/state'); | ||
var voidElements = require('./lib/void'); | ||
var _ = require('lodash'); | ||
import { Parser } from 'htmlparser2'; | ||
import Core from './lib/core.js'; | ||
import State from './lib/state.js'; | ||
import voidElements from './lib/void.js'; | ||
import _ from 'lodash'; | ||
@@ -15,3 +15,3 @@ var parxer = function(config, input, next) { | ||
var parser = new htmlparser.Parser({ | ||
var parser = new Parser({ | ||
onopentag: function(tagname, attribs) { | ||
@@ -95,5 +95,5 @@ | ||
module.exports = { | ||
export default { | ||
parxer: parxer, | ||
render: Core.render | ||
}; |
'use strict'; | ||
var Core = require('./core'); | ||
var _ = require('lodash'); | ||
import Core from './core.js'; | ||
import _ from 'lodash'; | ||
@@ -48,3 +48,3 @@ function getAttr(attr, attrs) { | ||
module.exports = { | ||
export default { | ||
getAttr: getAttr, | ||
@@ -51,0 +51,0 @@ parseAttribs: parseAttribs, |
'use strict'; | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
var urlLib = require('url'); | ||
import _ from'lodash'; | ||
import async from 'async'; | ||
import urlLib from 'url'; | ||
import attr from './attr.js'; | ||
@@ -79,4 +80,3 @@ function render(text, data) { | ||
function processDeferredStack(config, state, next) { | ||
var attr = require('./attr'); | ||
function processDeferredStack(config, state, next) { | ||
async.mapSeries(state.getDeferredStack(), function(deferred, cb) { | ||
@@ -160,3 +160,3 @@ var fragment = deferred.fragment; | ||
module.exports = { | ||
export default { | ||
render: render, | ||
@@ -163,0 +163,0 @@ matchPlugin: matchPlugin, |
'use strict'; | ||
var Core = require('../core'); | ||
var attr = require('../attr'); | ||
var _ = require('lodash'); | ||
import Core from '../core.js'; | ||
import attr from '../attr.js'; | ||
import _ from 'lodash'; | ||
module.exports = function(handler) { | ||
export default function(handler) { | ||
@@ -9,0 +9,0 @@ function match(tagname, attribs, config, state) { |
'use strict'; | ||
var Core = require('../core'); | ||
var attr = require('../attr'); | ||
import Core from '../core.js'; | ||
import attr from '../attr.js'; | ||
@@ -13,5 +13,5 @@ function match(tagname, attribs, config) { | ||
module.exports = { | ||
export default { | ||
name:'direct', | ||
match: match | ||
}; |
'use strict'; | ||
var Core = require('../core'); | ||
var attr = require('../attr'); | ||
import Core from '../core.js'; | ||
import attr from '../attr.js'; | ||
@@ -36,5 +36,5 @@ function match(tagname, attribs, config, state) { | ||
module.exports = { | ||
export default { | ||
name:'if', | ||
match: match | ||
}; |
'use strict'; | ||
var Core = require('../core'); | ||
var attr = require('../attr'); | ||
import Core from '../core.js'; | ||
import attr from '../attr.js'; | ||
@@ -18,5 +18,5 @@ function match(tagname, attribs, config, state) { | ||
module.exports = { | ||
export default { | ||
name:'test', | ||
match: match | ||
}; |
'use strict'; | ||
var Core = require('../core'); | ||
var attr = require('../attr'); | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
import Core from '../core.js'; | ||
import attr from '../attr.js'; | ||
import _ from 'lodash'; | ||
import async from 'async'; | ||
@@ -26,3 +26,3 @@ var strategyDict = { | ||
module.exports = function (handler) { | ||
export default function (handler) { | ||
@@ -29,0 +29,0 @@ var parsedAttribs = ['url', 'cache-key', 'no-cache']; |
@@ -1,2 +0,2 @@ | ||
var _ = require('lodash'); | ||
import _ from 'lodash'; | ||
@@ -205,4 +205,4 @@ function create(config) { | ||
module.exports = { | ||
export default { | ||
create: create | ||
} |
@@ -6,3 +6,3 @@ /** | ||
module.exports = { | ||
export default { | ||
area: true, | ||
@@ -9,0 +9,0 @@ base: true, |
{ | ||
"name": "pxr", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"description": "HTML transformation library built on top of HTMLParser2, used by Compoxure.", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "lint": "jshint .", |
@@ -1,7 +0,13 @@ | ||
module.exports = { | ||
Url: require('./lib/plugins/url'), | ||
Test: require('./lib/plugins/test'), | ||
If: require('./lib/plugins/if'), | ||
Direct: require('./lib/plugins/direct'), | ||
DefineSlot: require('./lib/plugins/define-slot') | ||
import Url from './lib/plugins/url.js'; | ||
import Test from './lib/plugins/test.js'; | ||
import DefineSlot from './lib/plugins/define-slot.js'; | ||
import If from './lib/plugins/if.js'; | ||
import Direct from './lib/plugins/direct.js'; | ||
export default { | ||
Url, | ||
Test, | ||
If, | ||
Direct, | ||
DefineSlot | ||
}; |
'use strict'; | ||
var expect = require('expect.js'); | ||
var parxer = require('..').parxer; | ||
var render = require('..').render; | ||
var cheerio = require('cheerio'); | ||
var fs = require('fs'); | ||
import expect from 'expect.js'; | ||
import pxr from '../index.js'; | ||
import cheerio from 'cheerio'; | ||
import fs from 'fs'; | ||
import Plugins from '../Plugins.js'; | ||
describe("Core html parsing", function() { | ||
const parxer = pxr.parxer; | ||
const render = pxr.render; | ||
it('should parse a valid html document unchanged', function(done) { | ||
@@ -32,3 +35,3 @@ var input = "<html></html>"; | ||
plugins: [ | ||
require('../Plugins').Test | ||
Plugins.Test | ||
], | ||
@@ -35,0 +38,0 @@ variables: { |
'use strict'; | ||
var expect = require('expect.js'); | ||
var parxer = require('..').parxer; | ||
var render = require('..').render; | ||
var cheerio = require('cheerio'); | ||
import expect from 'expect.js'; | ||
import pxr from '../index.js'; | ||
import cheerio from 'cheerio'; | ||
import fs from 'fs'; | ||
import Plugins from '../Plugins.js'; | ||
describe("Define slot parsing", function() { | ||
const parxer = pxr.parxer; | ||
const render = pxr.render; | ||
it('should parse define slot attributes and insert the content', function(done) { | ||
@@ -14,3 +18,3 @@ var input = "<html><div id='library'><div cx-define-slot='hello'></div></div></html>"; | ||
plugins: [ | ||
require('../Plugins').DefineSlot(function(fragment, next) { next(null, fragment.attribs['cx-define-slot']) }) | ||
Plugins.DefineSlot(function(fragment, next) { next(null, fragment.attribs['cx-define-slot']) }) | ||
], | ||
@@ -37,3 +41,3 @@ cdn: { | ||
plugins: [ | ||
require('../Plugins').DefineSlot(function(fragment, next) { next(null, fragment.attribs['cx-define-slot']) }) | ||
Plugins.DefineSlot(function(fragment, next) { next(null, fragment.attribs['cx-define-slot']) }) | ||
], | ||
@@ -60,3 +64,3 @@ cdn: { | ||
plugins: [ | ||
require('../Plugins').DefineSlot(function(fragment, next) { next(null, fragment.attribs['cx-define-slot']) }) | ||
Plugins.DefineSlot(function(fragment, next) { next(null, fragment.attribs['cx-define-slot']) }) | ||
], | ||
@@ -63,0 +67,0 @@ cdn: { |
'use strict'; | ||
var expect = require('expect.js'); | ||
var parxer = require('..').parxer; | ||
var render = require('..').render; | ||
var cheerio = require('cheerio'); | ||
var fs = require('fs'); | ||
import expect from 'expect.js'; | ||
import pxr from '../index.js'; | ||
import cheerio from 'cheerio'; | ||
import fs from 'fs'; | ||
import Plugins from '../Plugins.js'; | ||
describe("If logic plugin", function() { | ||
const parxer = pxr.parxer; | ||
const render = pxr.render; | ||
it('should parse if attributes and retain block if true', function(done) { | ||
@@ -15,3 +18,3 @@ var input = "<html><div id='if' cx-if='${server:name}' cx-if-value='http://www.google.com'><h1>Hello</h1><span id='stillhere'>Rah!</span></div></html>"; | ||
plugins: [ | ||
require('../Plugins').If | ||
Plugins.If | ||
], | ||
@@ -32,3 +35,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').If | ||
Plugins.If | ||
], | ||
@@ -50,3 +53,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').If | ||
Plugins.If | ||
], | ||
@@ -67,3 +70,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').If | ||
Plugins.If | ||
], | ||
@@ -84,4 +87,4 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').If, | ||
require('../Plugins').Url(function(fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.If, | ||
Plugins.Url(function(fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -88,0 +91,0 @@ variables: { |
'use strict'; | ||
var expect = require('expect.js'); | ||
var parxer = require('..').parxer; | ||
var render = require('..').render; | ||
var cheerio = require('cheerio'); | ||
var fs = require('fs'); | ||
import expect from 'expect.js'; | ||
import pxr from '../index.js'; | ||
import cheerio from 'cheerio'; | ||
import fs from 'fs'; | ||
import Plugins from '../Plugins.js'; | ||
describe("Url parsing", function () { | ||
const parxer = pxr.parxer; | ||
const render = pxr.render; | ||
it('should parse url attributes', function (done) { | ||
@@ -15,3 +18,3 @@ var input = "<html><div id='url' cx-url='${server:name}'>I am some default text</div></html>"; | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -32,3 +35,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -49,4 +52,4 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Test, | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Test, | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -70,3 +73,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['data-my-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['data-my-url']) }) | ||
], | ||
@@ -88,3 +91,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { setTimeout(function () { next(null, fragment.attribs['cx-url']) }, 40); }) | ||
Plugins.Url(function (fragment, next) { setTimeout(function () { next(null, fragment.attribs['cx-url']) }, 40); }) | ||
], | ||
@@ -107,3 +110,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
Plugins.Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
], | ||
@@ -124,3 +127,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -141,3 +144,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -160,3 +163,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
Plugins.Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
], | ||
@@ -179,3 +182,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
Plugins.Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
], | ||
@@ -199,3 +202,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
Plugins.Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
], | ||
@@ -219,3 +222,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
Plugins.Url(function (fragment, next) { setTimeout(function () { next('Arrghh'); }, 20) }) | ||
], | ||
@@ -236,3 +239,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -253,3 +256,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -271,3 +274,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
Plugins.Url(function (fragment, next) { next(null, fragment.attribs['cx-url']) }) | ||
], | ||
@@ -293,3 +296,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, contents[fragment.attribs['cx-url']]) }) | ||
Plugins.Url(function (fragment, next) { next(null, contents[fragment.attribs['cx-url']]) }) | ||
], | ||
@@ -315,3 +318,3 @@ variables: { | ||
plugins: [ | ||
require('../Plugins').Url(function (fragment, next) { next(null, contents[fragment.attribs['cx-url']]) }) | ||
Plugins.Url(function (fragment, next) { next(null, contents[fragment.attribs['cx-url']]) }) | ||
], | ||
@@ -318,0 +321,0 @@ variables: { |
'use strict'; | ||
var expect = require('expect.js'); | ||
var attr = require('../lib/attr'); | ||
import attr from '../lib/attr.js'; | ||
import expect from 'expect.js'; | ||
@@ -6,0 +6,0 @@ describe("attr", function () { |
1712
Yes
548010
5