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

markdown-utils

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-utils - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

165

index.js

@@ -16,54 +16,2 @@ /*!

/**
* Create a markdown-formatted anchor link from the given values.
*
* ```js
* utils.anchor('embed', 'assemble/handlebars-helpers/lib/code.js', 25, 'v0.6.0');
* //=> [embed](https://github.com/assemble/handlebars-helpers/blob/v0.6.0/lib/helpers/code.js#L25)
* ```
*
* @name anchor
* @param {String} `anchor`
* @param {String} `href`
* @param {String} `title`
* @api public
*/
exports.anchor = function anchor(text, repo, line, branch) {
return '[' + text + '](' + format(repo, branch, line) + ')';
};
function format(str, branch, line) {
var segs = str.split(/[\\\/]/);
var repo = slice(segs, 0, 2).join('/');
var rest = slice(segs, 2).join('/');
if (isNumber(branch)) {
line = branch;
branch = 'master';
}
var res = 'https://github.com/';
res += (repo + '/blob/' + branch + '/' + rest);
res += (line ? '#L' + line : '');
return res;
}
/**
* Create a markdown-formatted badge.
*
* ```js
* utils.badge(alt, img_url, url);
* //=> [![Build Status](https://travis-ci.org/jonschlinkert/template.svg)](https://travis-ci.org/jonschlinkert/template)
* ```
*
* @name badge
* @param {String} `alt`
* @param {String} `img_url`
* @param {String} `url`
* @api public
*/
exports.badge = function badge(alt, img_url, url) {
return exports.link(exports.image(alt, img_url), url);
};
/**
* Create a markdown-formatted blockquote.

@@ -292,2 +240,73 @@ *

/**
* Create a markdown-formatted link from the given values.
*
* ```js
* utils.link('fs-utils', 'https://github.com/assemble/fs-utils', 'hover title');
* //=> [fs-utils](https://github.com/assemble/fs-utils "hover title")
* ```
*
* @name link
* @param {String} `anchor`
* @param {String} `href`
* @param {String} `title`
* @api public
*/
exports.link = function link(anchor, href, title) {
return '[' + anchor + '](' + href + (title ? ' "' + title + '"' : '') + ')';
};
/**
* Create a markdown-formatted anchor link from the given values.
*
* ```js
* utils.anchor('embed', 'assemble/handlebars-helpers/lib/code.js', 25, 'v0.6.0');
* //=> [embed](https://github.com/assemble/handlebars-helpers/blob/v0.6.0/lib/helpers/code.js#L25)
* ```
*
* @name anchor
* @param {String} `anchor`
* @param {String} `href`
* @param {String} `title`
* @api public
*/
exports.anchor = function anchor(text, repo, line, branch) {
return '[' + text + '](' + format(repo, branch, line) + ')';
};
function format(str, branch, line) {
var segs = str.split(/[\\\/]/);
var repo = slice(segs, 0, 2).join('/');
var rest = slice(segs, 2).join('/');
if (isNumber(branch)) {
line = branch;
branch = 'master';
}
var res = 'https://github.com/';
res += (repo + '/blob/' + branch + '/' + rest);
res += (line ? '#L' + line : '');
return res;
}
/**
* Create a markdown-formatted reference link from the given values.
*
* ```js
* utils.reference('template', 'https://github/jonschlinkert/template', 'Make stuff!');
* //=> [template]: https://github/jonschlinkert/template "Make stuff!"
* ```
*
* @name reference
* @param {String} `id`
* @param {String} `url`
* @param {String} `title`
* @api public
*/
exports.reference = function reference(id, url, title) {
return '[' + id + ']: ' + url + (title ? ' "' + title + '"' : '');
};
/**
* Create a markdown-formatted image from the given values.

@@ -311,24 +330,22 @@ *

exports.image = function image(alt, src, title) {
title = title ? ' "' + title + '"' : '';
return '![' + alt + '](' + src + title + ')';
return '!' + exports.link(alt, src, title);
};
/**
* Create a markdown-formatted link from the given values.
* Create a markdown-formatted badge.
*
* ```js
* utils.link('fs-utils', 'https://github.com/assemble/fs-utils', 'hover title');
* //=> [fs-utils](https://github.com/assemble/fs-utils "hover title")
* utils.badge(alt, img_url, url);
* //=> [![Build Status](https://travis-ci.org/jonschlinkert/template.svg)](https://travis-ci.org/jonschlinkert/template)
* ```
*
* @name link
* @param {String} `anchor`
* @param {String} `href`
* @param {String} `title`
* @name badge
* @param {String} `alt`
* @param {String} `img_url`
* @param {String} `url`
* @api public
*/
exports.link = function link(anchor, href, title) {
title = title ? ' "' + title + '"' : '';
return '[' + anchor + '](' + href + title + ')';
exports.badge = function badge(alt, img_url, url, title) {
return exports.link(exports.image(alt, img_url, title), url);
};

@@ -428,22 +445,2 @@

/**
* Create a markdown-formatted reference link from the given values.
*
* ```js
* utils.reference('template', 'https://github/jonschlinkert/template', 'Make stuff!');
* //=> [template]: https://github/jonschlinkert/template "Make stuff!"
* ```
*
* @name reference
* @param {String} `id`
* @param {String} `url`
* @param {String} `title`
* @api public
*/
exports.reference = function reference(id, url, title) {
title = title ? ' "' + title + '"' : '';
return '[' + id + ']: ' + url + title;
};
/**
* Create markdown-formatted bold text.

@@ -450,0 +447,0 @@ *

{
"name": "markdown-utils",
"description": "Micro-utils for creating markdown snippets.",
"version": "0.7.1",
"version": "0.7.2",
"homepage": "https://github.com/jonschlinkert/markdown-utils",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/markdown-utils.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/markdown-utils",
"bugs": {

@@ -19,4 +13,3 @@ "url": "https://github.com/jonschlinkert/markdown-utils/issues"

"files": [
"index.js",
"lib/"
"index.js"
],

@@ -31,5 +24,5 @@ "main": "index.js",

"dependencies": {
"array-slice": "^0.2.2",
"is-number": "^1.1.0",
"list-item": "^1.0.1",
"array-slice": "^0.2.3",
"is-number": "^2.1.0",
"list-item": "^1.1.1",
"to-gfm-code-block": "^0.1.1"

@@ -39,4 +32,3 @@ },

"for-own": "^0.1.2",
"mocha": "^2.2.5",
"should": "^5.0.1"
"gulp-format-md": "^0.1.8"
},

@@ -54,3 +46,28 @@ "keywords": [

"write"
]
],
"verb": {
"related": {
"list": [
"gfm-code-blocks",
"markdown-link",
"markdown-toc",
"remarkable"
]
},
"reflinks": [
"bullets",
"verb"
],
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
}
}

@@ -1,29 +0,13 @@

# markdown-utils [![NPM version](https://badge.fury.io/js/markdown-utils.svg)](http://badge.fury.io/js/markdown-utils) [![Build Status](https://travis-ci.org/jonschlinkert/markdown-utils.svg)](https://travis-ci.org/jonschlinkert/markdown-utils)
# markdown-utils [![NPM version](https://img.shields.io/npm/v/markdown-utils.svg?style=flat)](https://www.npmjs.com/package/markdown-utils) [![NPM downloads](https://img.shields.io/npm/dm/markdown-utils.svg?style=flat)](https://npmjs.org/package/markdown-utils) [![Build Status](https://img.shields.io/travis/jonschlinkert/markdown-utils.svg?style=flat)](https://travis-ci.org/jonschlinkert/markdown-utils)
> Micro-utils for creating markdown snippets.
Micro-utils for creating markdown snippets.
**Heads up!** `.list()` was removed in 0.6.0. If you still need this functionality use [bullets](https://github.com/jonschlinkert/bullets)instead.
## Install
Install with [npm](https://www.npmjs.com/)
Install with [npm](https://www.npmjs.com/):
```bash
npm i markdown-utils --save
```sh
$ npm install markdown-utils --save
```
## Table of Contents
<!-- toc -->
* [Usage](#usage)
* [API](#api)
* [Related](#related)
* [Running tests](#running-tests)
* [Contributing](#contributing)
* [Author](#author)
* [License](#license)
_(Table of contents generated by [verb])_
<!-- tocstop -->
## Usage

@@ -37,38 +21,4 @@

### [.anchor](index.js#L30)
### [.blockquote](index.js#L28)
Create a markdown-formatted anchor link from the given values.
**Params**
* `anchor` **{String}**
* `href` **{String}**
* `title` **{String}**
**Example**
```js
utils.anchor('embed', 'assemble/handlebars-helpers/lib/code.js', 25, 'v0.6.0');
//=> [embed](https://github.com/assemble/handlebars-helpers/blob/v0.6.0/lib/helpers/code.js#L25)
```
### [.badge](index.js#L63)
Create a markdown-formatted badge.
**Params**
* `alt` **{String}**
* `img_url` **{String}**
* `url` **{String}**
**Example**
```js
utils.badge(alt, img_url, url);
//=> [![Build Status](https://travis-ci.org/jonschlinkert/template.svg)](https://travis-ci.org/jonschlinkert/template)
```
### [.blockquote](index.js#L80)
Create a markdown-formatted blockquote.

@@ -87,3 +37,3 @@

### [.code](index.js#L97)
### [.code](index.js#L45)

@@ -103,3 +53,3 @@ Create a markdown-formatted `<code></code>` snippet.

### [.del](index.js#L114)
### [.del](index.js#L62)

@@ -119,3 +69,3 @@ Create markdown-formatted `<del></del>`.

### [.em](index.js#L131)
### [.em](index.js#L79)

@@ -135,3 +85,3 @@ Create a markdown-formatted em.

### [.h](index.js#L149)
### [.h](index.js#L97)

@@ -152,3 +102,3 @@ Create a markdown-formatted heading.

### [.h1](index.js#L166)
### [.h1](index.js#L114)

@@ -168,3 +118,3 @@ Create a markdown-formatted h1 heading.

### [.h2](index.js#L183)
### [.h2](index.js#L131)

@@ -184,3 +134,3 @@ Create a markdown-formatted h2 heading.

### [.h3](index.js#L200)
### [.h3](index.js#L148)

@@ -200,3 +150,3 @@ Create a markdown-formatted h3 heading.

### [.h4](index.js#L217)
### [.h4](index.js#L165)

@@ -216,3 +166,3 @@ Create a markdown-formatted h4 heading.

### [.h5](index.js#L234)
### [.h5](index.js#L182)

@@ -232,3 +182,3 @@ Create a markdown-formatted h5 heading.

### [.h6](index.js#L251)
### [.h6](index.js#L199)

@@ -248,3 +198,3 @@ Create a markdown-formatted h6 heading.

### [.heading](index.js#L269)
### [.heading](index.js#L217)

@@ -265,3 +215,3 @@ Create a markdown-formatted heading.

### [.hr](index.js#L286)
### [.hr](index.js#L234)

@@ -281,4 +231,55 @@ Create a markdown-formatted horizontal rule.

### [.image](index.js#L308)
### [.link](index.js#L253)
Create a markdown-formatted link from the given values.
**Params**
* `anchor` **{String}**
* `href` **{String}**
* `title` **{String}**
**Example**
```js
utils.link('fs-utils', 'https://github.com/assemble/fs-utils', 'hover title');
//=> [fs-utils](https://github.com/assemble/fs-utils "hover title")
```
### [.anchor](index.js#L272)
Create a markdown-formatted anchor link from the given values.
**Params**
* `anchor` **{String}**
* `href` **{String}**
* `title` **{String}**
**Example**
```js
utils.anchor('embed', 'assemble/handlebars-helpers/lib/code.js', 25, 'v0.6.0');
//=> [embed](https://github.com/assemble/handlebars-helpers/blob/v0.6.0/lib/helpers/code.js#L25)
```
### [.reference](index.js#L305)
Create a markdown-formatted reference link from the given values.
**Params**
* `id` **{String}**
* `url` **{String}**
* `title` **{String}**
**Example**
```js
utils.reference('template', 'https://github/jonschlinkert/template', 'Make stuff!');
//=> [template]: https://github/jonschlinkert/template "Make stuff!"
```
### [.image](index.js#L327)
Create a markdown-formatted image from the given values.

@@ -302,11 +303,11 @@

### [.link](index.js#L328)
### [.badge](index.js#L346)
Create a markdown-formatted link from the given values.
Create a markdown-formatted badge.
**Params**
* `anchor` **{String}**
* `href` **{String}**
* `title` **{String}**
* `alt` **{String}**
* `img_url` **{String}**
* `url` **{String}**

@@ -316,7 +317,7 @@ **Example**

```js
utils.link('fs-utils', 'https://github.com/assemble/fs-utils', 'hover title');
//=> [fs-utils](https://github.com/assemble/fs-utils "hover title")
utils.badge(alt, img_url, url);
//=> [![Build Status](https://travis-ci.org/jonschlinkert/template.svg)](https://travis-ci.org/jonschlinkert/template)
```
### [.li](index.js#L359)
### [.li](index.js#L376)

@@ -352,3 +353,3 @@ Returns a function to generate a plain-text/markdown list-item, allowing options to be cached for subsequent calls.

### [.pre](index.js#L383)
### [.pre](index.js#L400)

@@ -376,3 +377,3 @@ Create a markdown-formatted `<pre><code></code></pre>` snippet with or without lang.

### [.pre](index.js#L417)
### [.pre](index.js#L434)

@@ -400,21 +401,4 @@ Create a markdown-formatted code snippet with or without `lang`.

### [.reference](index.js#L439)
### [.strong](index.js#L454)
Create a markdown-formatted reference link from the given values.
**Params**
* `id` **{String}**
* `url` **{String}**
* `title` **{String}**
**Example**
```js
utils.reference('template', 'https://github/jonschlinkert/template', 'Make stuff!');
//=> [template]: https://github/jonschlinkert/template "Make stuff!"
```
### [.strong](index.js#L457)
Create markdown-formatted bold text.

@@ -433,3 +417,3 @@

### [.todo](index.js#L477)
### [.todo](index.js#L474)

@@ -452,9 +436,29 @@ Create a markdown-formatted todo item.

## Related
## Related projects
* [gfm-code-blocks](https://github.com/jonschlinkert/gfm-code-blocks): Extract gfm (GitHub Flavored Markdown) fenced code blocks from a string.
* [markdown-toc](https://github.com/jonschlinkert/markdown-toc): Generate a markdown TOC (table of contents) with Remarkable.
* [markdown-link](https://github.com/jonschlinkert/markdown-link): Micro util for generating a single markdown link.
* [remarkable](https://github.com/jonschlinkert/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://github.com/jonschlinkert/remarkable)
You might also be interested in these projects:
* [gfm-code-blocks](https://www.npmjs.com/package/gfm-code-blocks): Extract gfm (GitHub Flavored Markdown) fenced code blocks from a string. | [homepage](https://github.com/jonschlinkert/gfm-code-blocks)
* [markdown-link](https://www.npmjs.com/package/markdown-link): Micro util for generating a single markdown link. | [homepage](https://github.com/jonschlinkert/markdown-link)
* [markdown-toc](https://www.npmjs.com/package/markdown-toc): Generate a markdown TOC (table of contents) with Remarkable. | [homepage](https://github.com/jonschlinkert/markdown-toc)
* [remarkable](https://www.npmjs.com/package/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://www.npmjs.com/package/remarkable) | [homepage](https://github.com/jonschlinkert/remarkable)
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/markdown-utils/issues/new).
## Building docs
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install verb && npm run docs
```
Or, if [verb](https://github.com/verbose/verb) is installed globally:
```sh
$ verb
```
## Running tests

@@ -464,10 +468,6 @@

```bash
npm i -d && npm test
```sh
$ npm install -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/markdown-utils/issues)
## Author

@@ -477,12 +477,12 @@

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license.
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/markdown-utils/blob/master/LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 14, 2015._
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 23, 2016._

Sorry, the diff of this file is not supported yet

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