md-tags

1.2.5 • Public • Published

md-tags

NPM version Build Status Coveralls Status Dependency Status DevDependency Status

Extract tags from your markdown article

Install

npm install --save md-tags

Usage

import mdTags from 'md-tags';
 
const post1 = `
# Title
 
_January 30, 2016_
 
#nodejs, #markdown, #my-tag;`;
 
const post2 = `
# Title
 
_January 31, 2016_
 
#nodejs, #just-tag;`;
 
const post3 = `
# Title
 
_February 30, 2016_
 
#markdown, #my-tag;`;
 
let tags = mdTags().tagsForPost(post1);
tags.md;      // #nodejs, #markdown, #my-tag
tags.text;    // nodejs, markdown, my-tag
tags.list;    // ["nodejs", "markdown", "my-tag"]
 
let posts = [];
posts.push(post1,post2,post3);
 
let postsMatchedByTag = mdTags().postsForTag('my-tag', posts);
/*
[
    "# Title
    
    _January 30, 2016_
    
    #nodejs, #markdown, #my-tag"
    ,
    "# Title
    
    _February 30, 2016_
    
    #markdown, #my-tag"
]
*/
 

API

tagsForPost(post)

Return object {md: String, text: String, html: string, list: Array}.

post

Required
Type: String

Markdown string.

postsForTag(tag, posts)

Return list: Array array of posts in markdown syntax, which matches by tag.

tag

Required
Type: String

Tag for searching in posts.

posts

Required
Type: Array

Array of posts in markdown syntax

License

MIT © Aleksandr Filatov

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.50latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.50
1.2.40
1.2.30
1.2.20
1.2.10
1.1.10
1.1.00
1.0.00
0.0.40
0.0.30
0.0.10

Package Sidebar

Install

npm i md-tags

Weekly Downloads

0

Version

1.2.5

License

MIT

Last publish

Collaborators

  • greybax