Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@mattersmedia/html-to-article-json
Advanced tools
html-to-article-json parses & normalizes html to a well-structured & easy to use article json format.
The parsing logic is based on real articles - with sometimes very weird html - so please open an issue if some html doesn't get parsed correctly!
npm install html-to-article-json
var htmlToArticleJson = require('html-to-article-json')();
var htmlString = '<p>Foo<b>bar</b></p>';
var articleJson = htmlToArticleJson(htmlString);
Using browseriy html-to-article-json can also use DOM as input in the browser!
var htmlToArticleJson = require('html-to-article-json')();
var domElement = document.querySelector('article');
var articleJson = htmlToArticleJson(domElement);
article-json
consists of a list of nodes, each node representing a block of content.
Please see the example (npm run example
) for a simple WYSIWYG editor & the corresponding article json.
{
"type": "paragraph",
"children": [{
"type": "text",
"content": "Hello, ",
"href": null,
"italic": false,
"bold": false
}, {
"type": "text",
"content": "mic.com",
"href": "http://www.mic.com",
"italic": true,
"bold": false
}]
}
The above is an example of a text node - corresponding to something like <p>Hello, <a href="mic.com"><b>mic.com</b></a>
.
A text content node is defined by it's visual representation rather than it's code - so html-to-article-json
will parse <a href="mic.com"><b>mic.com</b></a>
and <b><a href="mic.com">mic.com</a></b>
to the same json object.
Valid text nodes are paragraph
, header1
, header2
, header3
, header4
, header5
& header6
.
{
"type": "embed",
"embedType": "youtube",
"youtubeId": "eBYFOJxZx4Q",
"caption": [{
"type": "text",
"content": "Here's a video from ",
"href": null,
"italic": false,
"bold": false
}, {
"type": "text",
"content": "mic.com",
"href": "http://www.mic.com",
"italic": true,
"bold": false
}]
}
The above is an example of an embed node - corresponding to a youtube embed. The caption format is the same as the children
array we have in the Text
example.
FAQs
Converting HTML to article-json
We found that @mattersmedia/html-to-article-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.