![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
AMP up your plain HTML. Replaces regular HTML tags with their equivalent AMP components.
npm install amperize
var Amperize = require('amperize');
var html = '<img src="https://example.com/image.jpg" />';
var amperize = new Amperize();
amperize.parse(html, function (error, result) {
if (error) {
// do something with error
return new Error(err);
}
// do something with result
return result;
});
Amperize is build to convert the <body>
part of your HTML. It will not create the AMP boilerplate and will not add the required <script>
for each component.
<amp-img>
Amperize will convert common <img>
tags into AMP HTML conform <amp-img>
tags. With the sub-dependencies [probe-image-size](https://github.com/nodeca/probe-image-size) and [
image-size](https://github.com/image-size/image-size), Amperize will fetch the necessary
widthand
height` properties for the given image.
It will fall back to the default values width: 600
and height: 400
, if the dimensions couldn't be fetched.
If any other error occurs (eg. missing src
property), Amperize will not transform the tag and return the original.
<amp-anim>
When the <img>
tag that needs to be transformed, is a .gif
animation, Amperize will convert it into <amp-anim>
, following the same rules as for <amp-img>
.
<amp-iframe>
Amperize converts iFrames like embedded videos from Vimeo, etc. into <amp-iframe>
tags. If the src
attribute is an http
URL it will be switched to https
in order to pass AMP validation.
<amp-youtube>
Amperize converts iFrames with a "YouTube" URL into <amp-youtube>
tags. If the src
attribute is an http
URL it will be switched to https
in order to pass AMP validation.
<amp-audio>
Converts HTML <audio>
into <amp-audio>
. If the src
attribute is an http
URL it will be switched to https
in order to pass AMP validation.
git clone git@github.com:jbhannah/amperize.git
cd amperize
npm install
npm run watch
npm run watch
will restart the tests on changes.
Running the test:
npm run test
Code coverage:
npm run coverage
Borrows heavily from Minimize, especially the constructor, parse
,
amperizer
, and traverse
functions in the Amperize
object, and the unit
tests. Copyright (c) 2013 Moveo - Martijn Swaagman. Used under the MIT License
(see LICENSE
).
FAQs
AMP up your plain HTML
The npm package amperize receives a total of 2,207 weekly downloads. As such, amperize popularity was classified as popular.
We found that amperize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.