Code Monkey home page Code Monkey logo

first-x's Introduction

First x

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

Build Status npm version Greenkeeper badge 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

first-x's People

Contributors

greenkeeper[bot] avatar webmasterish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.