markdown-utils
Advanced tools
Comparing version 0.6.1 to 0.7.0
43
index.js
@@ -13,2 +13,3 @@ /*! | ||
var listitem = require('list-item'); | ||
var codeBlock = require('to-gfm-code-block'); | ||
@@ -371,7 +372,7 @@ /** | ||
* | ||
* ```html | ||
* <pre> | ||
* ```js | ||
* var foo = bar; | ||
* </pre> | ||
* ``` | ||
* </pre> | ||
* | ||
@@ -384,8 +385,13 @@ * @name pre | ||
exports.pre = function pre(str, lang) { | ||
var code = '```' + (lang || ''); | ||
exports.pre = function pre(str) { | ||
if (typeof str !== 'string') { | ||
throw new TypeError('markdown-pre expects a string.'); | ||
} | ||
var code = ''; | ||
code += '<pre>' | ||
code += '\n'; | ||
code += str; | ||
code += '\n'; | ||
code += '```'; | ||
code += '</pre>'; | ||
return code; | ||
@@ -395,2 +401,29 @@ }; | ||
/** | ||
* Create a markdown-formatted code snippet with or without `lang`. | ||
* | ||
* ```js | ||
* utils.gfm('var foo = bar;', 'js'); | ||
* ``` | ||
* Results in: | ||
* | ||
* <pre> | ||
* ```js | ||
* var foo = bar; | ||
* ``` | ||
* </pre> | ||
* | ||
* @name pre | ||
* @param {String} `str` | ||
* @param {String} `language` | ||
* @api public | ||
*/ | ||
exports.gfm = function gfm(str, lang) { | ||
if (typeof str !== 'string') { | ||
throw new TypeError('markdown-gfm expects a string.'); | ||
} | ||
return codeBlock(str, lang); | ||
}; | ||
/** | ||
* Create a markdown-formatted reference link from the given values. | ||
@@ -397,0 +430,0 @@ * |
{ | ||
"name": "markdown-utils", | ||
"description": "Micro-utils for creating markdown snippets.", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"homepage": "https://github.com/jonschlinkert/markdown-utils", | ||
@@ -35,3 +35,4 @@ "author": { | ||
"is-number": "^1.1.0", | ||
"list-item": "^0.1.2" | ||
"list-item": "^0.1.2", | ||
"to-gfm-code-block": "^0.1.1" | ||
}, | ||
@@ -38,0 +39,0 @@ "devDependencies": { |
@@ -7,3 +7,3 @@ # 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) | ||
## Install with [npm](npmjs.org) | ||
Install with [npm](https://www.npmjs.com/) | ||
@@ -26,3 +26,3 @@ ```bash | ||
_(Table of contents generated by [verb](https://github.com/assemble/verb))_ | ||
_(Table of contents generated by [verb])_ | ||
@@ -39,3 +39,3 @@ <!-- tocstop --> | ||
### [.anchor](index.js#L29) | ||
### [.anchor](index.js#L30) | ||
@@ -57,3 +57,3 @@ Create a markdown-formatted anchor link from the given values. | ||
### [.badge](index.js#L62) | ||
### [.badge](index.js#L63) | ||
@@ -75,3 +75,3 @@ Create a markdown-formatted badge. | ||
### [.blockquote](index.js#L79) | ||
### [.blockquote](index.js#L80) | ||
@@ -91,3 +91,3 @@ Create a markdown-formatted blockquote. | ||
### [.code](index.js#L96) | ||
### [.code](index.js#L97) | ||
@@ -107,3 +107,3 @@ Create a markdown-formatted `<code></code>` snippet. | ||
### [.del](index.js#L113) | ||
### [.del](index.js#L114) | ||
@@ -123,3 +123,3 @@ Create markdown-formatted `<del></del>`. | ||
### [.em](index.js#L130) | ||
### [.em](index.js#L131) | ||
@@ -139,3 +139,3 @@ Create a markdown-formatted em. | ||
### [.h](index.js#L148) | ||
### [.h](index.js#L149) | ||
@@ -156,3 +156,3 @@ Create a markdown-formatted heading. | ||
### [.h1](index.js#L165) | ||
### [.h1](index.js#L166) | ||
@@ -172,3 +172,3 @@ Create a markdown-formatted h1 heading. | ||
### [.h2](index.js#L182) | ||
### [.h2](index.js#L183) | ||
@@ -188,3 +188,3 @@ Create a markdown-formatted h2 heading. | ||
### [.h3](index.js#L199) | ||
### [.h3](index.js#L200) | ||
@@ -204,3 +204,3 @@ Create a markdown-formatted h3 heading. | ||
### [.h4](index.js#L216) | ||
### [.h4](index.js#L217) | ||
@@ -220,3 +220,3 @@ Create a markdown-formatted h4 heading. | ||
### [.h5](index.js#L233) | ||
### [.h5](index.js#L234) | ||
@@ -236,3 +236,3 @@ Create a markdown-formatted h5 heading. | ||
### [.h6](index.js#L250) | ||
### [.h6](index.js#L251) | ||
@@ -252,3 +252,3 @@ Create a markdown-formatted h6 heading. | ||
### [.heading](index.js#L268) | ||
### [.heading](index.js#L269) | ||
@@ -269,3 +269,3 @@ Create a markdown-formatted heading. | ||
### [.hr](index.js#L285) | ||
### [.hr](index.js#L286) | ||
@@ -285,3 +285,3 @@ Create a markdown-formatted horizontal rule. | ||
### [.image](index.js#L307) | ||
### [.image](index.js#L308) | ||
@@ -306,3 +306,3 @@ Create a markdown-formatted image from the given values. | ||
### [.link](index.js#L327) | ||
### [.link](index.js#L328) | ||
@@ -324,3 +324,3 @@ Create a markdown-formatted link from the given values. | ||
### [.li](index.js#L358) | ||
### [.li](index.js#L359) | ||
@@ -356,3 +356,3 @@ Returns a function to generate a plain-text/markdown list-item, allowing options to be cached for subsequent calls. | ||
### [.pre](index.js#L382) | ||
### [.pre](index.js#L383) | ||
@@ -362,5 +362,28 @@ Create a markdown-formatted `<pre><code></code></pre>` snippet with or without lang. | ||
Results in: | ||
**Params** | ||
* `str` **{String}** | ||
* `language` **{String}** | ||
**Examples** | ||
```js | ||
utils.pre('var foo = bar;'); | ||
``` | ||
```html | ||
<pre> | ||
var foo = bar; | ||
</pre> | ||
``` | ||
### [.pre](index.js#L417) | ||
Create a markdown-formatted code snippet with or without `lang`. | ||
Results in: | ||
<pre> | ||
</pre> | ||
**Params** | ||
@@ -374,3 +397,3 @@ | ||
```js | ||
utils.pre('var foo = bar;'); | ||
utils.gfm('var foo = bar;', 'js'); | ||
``` | ||
@@ -382,3 +405,3 @@ | ||
### [.reference](index.js#L406) | ||
### [.reference](index.js#L439) | ||
@@ -400,3 +423,3 @@ Create a markdown-formatted reference link from the given values. | ||
### [.strong](index.js#L424) | ||
### [.strong](index.js#L457) | ||
@@ -416,3 +439,3 @@ Create markdown-formatted bold text. | ||
### [.todo](index.js#L444) | ||
### [.todo](index.js#L477) | ||
@@ -458,4 +481,4 @@ Create a markdown-formatted todo item. | ||
[github/jonschlinkert](https://github.com/jonschlinkert) | ||
[twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
@@ -469,4 +492,2 @@ ## License | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 29, 2015._ | ||
<!-- reflinks generated by verb-reflinks plugin --> | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 14, 2015._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20200
429
465
4
+ Addedto-gfm-code-block@^0.1.1
+ Addedto-gfm-code-block@0.1.1(transitive)