micnews / html-to-amp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo not working

mobihunterz opened this issue · comments

I have following implementation in my main.js file:

let htmlToAmp = require('html-to-amp');

const html = '<p>beep booop</p><img src="http://example.com/image.jpg" /><blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr"><a href="https://t.co/kt1c5RWajI">https://t.co/kt1c5RWajI</a>’s <a href="https://twitter.com/david_bjorklund">@david_bjorklund</a> published 2 node modules to convert HTML snippets to <a href="https://twitter.com/AMPhtml">@amphtml</a><a href="https://t.co/yB5KMDijh6">https://t.co/yB5KMDijh6</a></p>&mdash; Malte Ubl (@cramforce) <a href="https://twitter.com/cramforce/status/697485294531145730">February 10, 2016</a></blockquote> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>';

// can be used with callbacks
htmlToAmp(html, (err, amp) => {
  if (err) {
  	console.log("New AMP: " + err);
    throw err;
  }
  // do something with it
  console.log("New AMP: " + amp);
});

now when I run node main.js command, I have not output on screen, it seems the callback function is not being called. I wanted this code to at least print error or new AMP HTML.

@mobihunterz same issue here as in html-to-article-json, opts is optional so it should work if you just change the require to:

let htmlToAmp = require('html-to-amp')();

Readme and example updated with working example: 64fefbf

Thanks for flagging!