Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

first-x

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

first-x

Utility to extract the content of the first occurence of element x from HTML or Markdown

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

First x

Utility to extract the content of the first occurence of element x from HTML or Markdown

Build Status npm version MIT License

Install

$ npm install first-x

# or

$ 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 counterparts
  • HTML image tag (img) and it's markdown counterpart
  • HTML paragraph tag (p) and it's markdown counterpart
  • HTML 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 syntax
  • from_html - exclusively checks html
  • from_md (alias of from_markdown) - exclusively checks markdown

More details in Extractor class.

const FIRST = require('first-x');

// -----------------------------------------------------------------------------

// get first header text from some content

const title = FIRST.header.from_any( content );

// -----------------------------------------------------------------------------

// extract paragraph content exclusively from markdown

const description = FIRST.p.from_md( content );

// -----------------------------------------------------------------------------

// extract image url exclusively from html

const img_url = FIRST.img.from_html( content );

// -----------------------------------------------------------------------------

// get first found blockquote content

const quote = FIRST.blockquote.from_any( content );

License

MIT © webmasterish

Keywords

FAQs

Package last updated on 17 Jan 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc