Create oEmbed JSON from HTML
Install with npm:
$ npm install --save-dev html2oembed
Via code:
const html2oembed = require('html2oembed');
const html = '<html><head><title>My awesome app</title><link href="/css/app.61f9f8cc.css" rel="stylesheet"></head><body><div id="app"></div><script type="text/javascript" src="/js/chunk-vendors.e42a3317.js"></script><script type="text/javascript" src="/js/app.c0e16a2e.js"></script></body></html>';
const parsed = html2oembed.parse(html);
const json = JSON.stringify(parsed);
Via CLI:
# Display help
$ npx html2oembed --help
# Convert HTML to oEmbed JSON
$ npx html2oembed convert ./index.html ./oembed.json
{
"version": "1.0",
"type": "rich",
"title": "My awesome app",
"html": "<link href=\"/css/app.61f9f8cc.css\" rel=\"stylesheet\"><div id=\"app\"></div><script type=\"text/javascript\" src=\"/js/chunk-vendors.e42a3317.js\"></script><script type=\"text/javascript\" src=\"/js/app.c0e16a2e.js\"></script>",
"width": "100%",
"height": "100%"
}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.