First x
Utility to extract the content of the first occurence of element x from HTML or Markdown
Install
$ npm install first-x
$ yarn add -D first-x
Usage
The following HTML
and markdown
elements/syntaxt are supported
using relevant functions:
HTML
header tags (h1
, h2
, h3
, etc...) and their markdown
counterpartsHTML
image tag (img
) and it's markdown
counterpartHTML
paragraph tag (p
) and it's markdown
counterpartHTML
blockquote tag (blockquote
) and it's markdown
counterpart
All supported elements/syntaxt have the following functions available:
from_any
- extracts content from first found occurence regardless of syntaxfrom_html
- exclusively checks html
from_md
(alias of from_markdown
) - exclusively checks markdown
More details in Extractor class
.
const FIRST = require('first-x');
const title = FIRST.header.from_any( content );
const description = FIRST.p.from_md( content );
const img_url = FIRST.img.from_html( content );
const quote = FIRST.blockquote.from_any( content );
License
MIT © webmasterish