@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-dev.3401+b483af77f", | ||
"license": "MIT", | ||
"version": "2.12.1-dev.3443+d1170cfc7", | ||
"license": "(MIT OR Apache-2.0)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
@@ -16,8 +19,8 @@ "type": "git", | ||
"node": ">= 16.0.0", | ||
"parcel": "^2.12.1-dev.3401+b483af77f" | ||
"parcel": "^2.12.1-dev.3443+d1170cfc7" | ||
}, | ||
"dependencies": { | ||
"@atlaspack/diagnostic": "2.12.1-dev.3401+b483af77f", | ||
"@atlaspack/plugin": "2.12.1-dev.3401+b483af77f", | ||
"@atlaspack/rust": "2.12.1-dev.3401+b483af77f", | ||
"@atlaspack/diagnostic": "2.12.1-dev.3443+d1170cfc7", | ||
"@atlaspack/plugin": "2.12.1-dev.3443+d1170cfc7", | ||
"@atlaspack/rust": "2.12.1-dev.3443+d1170cfc7", | ||
"nullthrows": "^1.1.1", | ||
@@ -30,3 +33,6 @@ "posthtml": "^0.16.5", | ||
}, | ||
"gitHead": "b483af77f02d1258c8dad156e097b94f83671d8e" | ||
"devDependencies": { | ||
"@atlaspack/core": "2.12.1-dev.3443+d1170cfc7" | ||
}, | ||
"gitHead": "d1170cfc79beb290b2a066f472f68f71f7d7cb23" | ||
} |
// @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
53191
19.54%9
12.5%1436
32.84%1
Infinity%