1.0.5 • Published 7 years ago

spark-messages v1.0.5

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

spark-messages Build Status XO code style

A collection of helpers to ensure consistent formatting of Cisco spark messages.

spark-messages may be redudant in some regards, but there are some side-benefits:

  • Any changes to markdown interpretation is corrected outside of source code
  • Ensure the usage of only a supported set of markdown -- no need to "guess and check"
  • HTML/CSS-like methods for easier referencing and implicit behavior
  • Programmability

Install

$ npm install --save spark-messages

Usage

const sm = require('spark-messages');

const message = `
${sm.h1('🦄 Unicorn Town')}
${sm.hr()}
For more info, click ${sm.link('http://unicornland.com', 'here')}!`
//=>
# 🦄 Unicorn Town
___
For more info, click [here](http://unicornland.com)!

Advance Usages

Mass editing a set of links

const sm = require('spark-messages');

const links = [
	'http://google.com',
	'http://facebook.com',
	'http://instagram.com'
];

const mdLinks = links.map(sm.link);
const boldLinks = mdLinks.map(sm.bold);
const mdLinkList = sm.ol(boldLinks);

// SHORT-HAND: sm.ol(links.map(raw => sm.link(sm.bold(raw))))
// =>
//   1. **<http://google.com>**
//   2. **<http://facebook.com>**
//   3. **<http://instagram.com>**

API

Preview the Spark Messages Wiki for visual reference of Spark output and examples.

Elements

h{n}(text)

h1(text), h2(text), h3(text), h4(text), h5(text), h6(text)

Text

Type: string

Text to be a header.

link(href, title)

Alias: a(), anchor()

href

Type: string

Url for the link

title

Type: string

Mask for the link.

email(emailAddress, title)

emailAddress

Type: string

Email address to create an link email. HTML equivalent = <a href="mailto:emailaddress">emailAddress</a>

title

Type: string

Mask for the email.

telephone(telephoneNumber, title)

Alias: tel()

telephoneNumber

Type: string

Telephone number to be an tel:.

title

Type: string

Mask for the telephone number.

unorderedList(items)

Alias: ul(items)

items

Type: array

List of items to be individually transformed to unordered list items.

orderedList(items)

Alias: ol(items)

items

Type: array

List of items to be individually transformed to unordered list items.

unorderedList(items)

Alias: ul(items)

items

Type: array

List of items to be individually transformed to ordered list items.

Font Style

bold(text)

Alias: b(), heavy()

Text

Type: string

Text to be bolded.

italic(text)

Alias: i(text), em(text), emphasis(text)

Text

Type: string

Text to be italicize.

code(text)

Alias: c(text)

Text

Type: string

Text to be transformed into a code style.

codeBlock(text)

Alias: cb(text)

Text

Type: string

Text to be transformed into a code block style.

Visual Elements

horizontalRule()

Alias: hr()

Returns a markdown horziontal rule (___).

lineBreak()

Alias: br()

Returns a linebreak.

License

MIT © Brandon Him

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago