Skip to content

phortuin/markdown-description

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-description Build Status

Parses description from Markdown-formatted text

Install

$ npm install markdown-description

Usage

const markdownDescription = require('markdown-description')

let markdown = `
# Title

The first paragraph is the [description](https://example.com).

This paragraph is here for decorative purposes only. 👋
`

let description = markdownDescription(markdown) //=> The first paragraph is the description.

API

markdownDescription(markdown, [options])

Returns a string or undefined.

markdown

Type: string

Markdown string to be parsed.

options

Type: object

concatLines

Type: boolean
Default: false

Concatenates lines, meaning it replaces newline characters with spaces and as such regards anything after the heading as the description.

let description = markdownDescription(markdown, { concatLines: true }) //=> The first paragraph is the description. This paragraph is here for decorative purposes only. 👋

Notes

  • Maximum length of the description is 160 characters; this is generally agreed upon to be the maximum visible amount of characters on a Google SERP. The description will be cut off on the latest possible space character within that range.
  • Lines starting with one or more spaces are skipped.
  • A heading (one or more pound # marks at the start of the line) is skipped.
  • Markdown formatting is stripped.

License

MIT © Anne Fortuin

About

Parses description from Markdown-formatted text

Resources

License

Stars

Watchers

Forks

Packages

No packages published