GithubHelp home page GithubHelp logo

readme-badger's Introduction

readme-badger

Build Status

Whizzy badges in your READMEs.

Install

npm install readme-badger

How To Use

addBadge(content, fileExt, imageUrl, linkUrl, altText)

Returns the content but with a new badge inserted.

  • content: the text content of a README.
  • fileExt: the file extension of the README (md, textile, rdoc etc).
  • imageUrl: the image url for the badge.
  • linkUrl: the url for the badge to link to.
  • altText: the alternative if images aren't visible. This will be used on its own for plaintext READMEs, so include a url in the text.

hasImageSupport(fileExt)

Returns true/false depending on whether the format (fileExt) will render a badge image or just the altText.

  • fileExt: the file extension of the README (md, textile, rdoc etc)

Example

var badger = require('readme-badger');

var readme = '# My Lovely Library\n' +
             '\n' +
             '## Features\n';
var imageUrl = 'https://badges.gitter.im/Join%20Chat.svg';
var linkUrl = 'https://gitter.im/gitterHQ/gitter';
var altText = 'Join the chat at https://gitter.im/gitterHQ/gitter';

var readmeWithBadge = badger.addBadge(readme, 'md', imageUrl, linkUrl, altText);

console.log(readmeWithBadge);
// # My Lovely Library
//
// [![Join the chat at https://gitter.im/gitterHQ/gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gitterHQ/gitter)
//
// ## Features
// ...

Format (fileExt) Support

readme-badger supports almost all of the GitHub README markups:

It will also failover to inserting the altText at the bottom of the README for any format that doesnt have image link support (creole, txt or anything else).

Building Locally

  1. git clone [email protected]:gitterHQ/readme-badger.git
  2. cd readme-badger
  3. npm install
  4. npm test

License

MIT

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.