npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amperize

v0.6.1

Published

AMP up your plain HTML

Downloads

12,176

Readme

Amperize

Version npm Build Status Dependencies Coverage Status

AMP up your plain HTML. Replaces regular HTML tags with their equivalent AMP components.

Installation

npm install amperize

Node.js

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;
});

Restrictions

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.

Currently supported AMP HTML components

<amp-img>

<amp-img> reference

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 widthandheight` 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>

<amp-anim> reference

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>

<amp-iframe> reference

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>

<amp-youtube> reference

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>

<amp-audio> reference

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.

Development

git clone [email protected]:jbhannah/amperize.git

cd amperize

npm install

npm run watch

npm run watch will restart the tests on changes.

Tests

Running the test:

npm run test

Code coverage:

npm run coverage

Credits

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).