This repository has been archived by the owner on Mar 11, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuanqing
committed
Aug 23, 2014
1 parent
7a1f26d
commit d1867c7
Showing
6 changed files
with
82 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
coverage/ | ||
node_modules/ | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Hashbrown.js [![npm Version](http://img.shields.io/npm/v/hashbrown.svg?style=flat)](https://www.npmjs.org/package/hashbrown) [![Build Status](https://img.shields.io/travis/yuanqing/hashbrown.svg?style=flat)](https://travis-ci.org/yuanqing/hashbrown) [![Coverage Status](https://img.shields.io/coveralls/yuanqing/hashbrown.svg?style=flat)](https://coveralls.io/r/yuanqing/hashbrown) | ||
|
||
> Extract tags inlined within a Markdown string. | ||
## Usage | ||
|
||
Hashbrown is an experiment in embedding meta data within running text. It is similar to the concept of the [hashtag](https://support.twitter.com/articles/49309-using-hashtags-on-twitter), only that **the post-processed text is syntactically correct**. This is because the `#(` and `)` markup used to demarcate a tag is removed from the text. | ||
|
||
```js | ||
var str = '#( Lorem ipsum! ) Dolor #( sit ) amet!'; | ||
|
||
hashbrown(str); | ||
/* => | ||
* { | ||
* text: '<p>Lorem ipsum! Dolor sit amet!</p>\n', | ||
* tags: ['lorem-ipsum', 'sit'] | ||
* } | ||
*/ | ||
``` | ||
|
||
A tag is converted to [kebab-case](http://stackoverflow.com/a/12273101/348359) as follows: | ||
|
||
1. Discard any character that isn’t alphanumeric, whitespace, a dash, or an underscore. | ||
2. Replace whitespace and underscore characters with a dash. | ||
|
||
## API | ||
|
||
### hashbrown(str) | ||
|
||
Parses the given Markdown-formatted `str`, and returns an object containing the processed `text`, and an array of `tags`. | ||
|
||
## Installation | ||
|
||
Install via [npm](https://www.npmjs.org/package/hashbrown): | ||
|
||
```bash | ||
$ npm i --save hashbrown | ||
``` | ||
|
||
## License | ||
|
||
[MIT license](https://github.com/yuanqing/hashbrown/blob/master/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters