spark-messages

1.0.5 • Public • Published

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

Package Sidebar

Install

npm i spark-messages

Weekly Downloads

6

Version

1.0.5

License

MIT

Last publish

Collaborators

  • brh55