@atlaspack/transformer-html
Advanced tools
Comparing version
@@ -7,2 +7,4 @@ "use strict"; | ||
exports.default = void 0; | ||
exports.parseHTML = parseHTML; | ||
exports.transformerOpts = void 0; | ||
function _plugin() { | ||
@@ -60,3 +62,15 @@ const data = require("@atlaspack/plugin"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = exports.default = new (_plugin().Transformer)({ | ||
function parseHTML(code, xmlMode) { | ||
return { | ||
type: 'posthtml', | ||
version: '0.4.1', | ||
program: (0, _posthtmlParser().parser)(code, { | ||
lowerCaseTags: true, | ||
lowerCaseAttributeNames: true, | ||
sourceLocations: true, | ||
xmlMode | ||
}) | ||
}; | ||
} | ||
const transformerOpts = exports.transformerOpts = { | ||
canReuseAST({ | ||
@@ -70,12 +84,5 @@ ast | ||
}) { | ||
return { | ||
type: 'posthtml', | ||
version: '0.4.1', | ||
program: (0, _posthtmlParser().parser)(await asset.getCode(), { | ||
lowerCaseTags: true, | ||
lowerCaseAttributeNames: true, | ||
sourceLocations: true, | ||
xmlMode: asset.type === 'xhtml' | ||
}) | ||
}; | ||
const code = await asset.getCode(); | ||
const xmlMode = asset.type === 'xhtml'; | ||
return parseHTML(code, xmlMode); | ||
}, | ||
@@ -159,3 +166,4 @@ async transform({ | ||
} | ||
}); | ||
}; | ||
var _default = exports.default = new (_plugin().Transformer)(transformerOpts); | ||
function findFirstMatch(ast, expressions) { | ||
@@ -162,0 +170,0 @@ let found; |
{ | ||
"name": "@atlaspack/transformer-html", | ||
"version": "2.12.1-canary.3413+2c4ca0fe0", | ||
"version": "2.12.1-canary.3414+889c7231e", | ||
"license": "(MIT OR Apache-2.0)", | ||
@@ -8,2 +8,5 @@ "publishConfig": { | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
@@ -17,8 +20,8 @@ "type": "git", | ||
"node": ">= 16.0.0", | ||
"parcel": "2.12.1-canary.3413+2c4ca0fe0" | ||
"parcel": "2.12.1-canary.3414+889c7231e" | ||
}, | ||
"dependencies": { | ||
"@atlaspack/diagnostic": "2.12.1-canary.3413+2c4ca0fe0", | ||
"@atlaspack/plugin": "2.12.1-canary.3413+2c4ca0fe0", | ||
"@atlaspack/rust": "2.12.1-canary.3413+2c4ca0fe0", | ||
"@atlaspack/diagnostic": "2.12.1-canary.3414+889c7231e", | ||
"@atlaspack/plugin": "2.12.1-canary.3414+889c7231e", | ||
"@atlaspack/rust": "2.12.1-canary.3414+889c7231e", | ||
"nullthrows": "^1.1.1", | ||
@@ -31,3 +34,6 @@ "posthtml": "^0.16.5", | ||
}, | ||
"gitHead": "2c4ca0fe08721406e9fc3eb448fdf64d3766a69d" | ||
"devDependencies": { | ||
"@atlaspack/core": "2.12.1-canary.3414+889c7231e" | ||
}, | ||
"gitHead": "889c7231ea7d5c51cc1cc5925151a8717d8ef882" | ||
} |
// @flow | ||
import {Transformer} from '@atlaspack/plugin'; | ||
import type {AST} from '@atlaspack/types'; | ||
import type {AST, Transformer as TransformerOpts} from '@atlaspack/types'; | ||
import {parser as parse} from 'posthtml-parser'; | ||
@@ -15,3 +15,16 @@ import nullthrows from 'nullthrows'; | ||
export default (new Transformer({ | ||
export function parseHTML(code: string, xmlMode: boolean): AST { | ||
return { | ||
type: 'posthtml', | ||
version: '0.4.1', | ||
program: parse(code, { | ||
lowerCaseTags: true, | ||
lowerCaseAttributeNames: true, | ||
sourceLocations: true, | ||
xmlMode, | ||
}), | ||
}; | ||
} | ||
export const transformerOpts: TransformerOpts<void> = { | ||
canReuseAST({ast}) { | ||
@@ -22,12 +35,5 @@ return ast.type === 'posthtml' && semver.satisfies(ast.version, '^0.4.0'); | ||
async parse({asset}) { | ||
return { | ||
type: 'posthtml', | ||
version: '0.4.1', | ||
program: parse(await asset.getCode(), { | ||
lowerCaseTags: true, | ||
lowerCaseAttributeNames: true, | ||
sourceLocations: true, | ||
xmlMode: asset.type === 'xhtml', | ||
}), | ||
}; | ||
const code = await asset.getCode(); | ||
const xmlMode = asset.type === 'xhtml'; | ||
return parseHTML(code, xmlMode); | ||
}, | ||
@@ -111,3 +117,4 @@ | ||
}, | ||
}): Transformer); | ||
}; | ||
export default (new Transformer(transformerOpts): Transformer); | ||
@@ -114,0 +121,0 @@ function findFirstMatch( |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
50728
13.93%9
12.5%1332
23.22%1
Infinity%