Create a new instance of ampifier
$ampifier = new ContentAmpifier();
Grab your html content from any source
$html = "<html>...</html>";
Convert it to amp
$amp = $ampifier->ampify($html);
This code is free to use. Please feel free to comment, add your suggestions etc. And you happen to use it in any project, I would be happy to know.