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
$ npm install --save spark-messages
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)!
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>**
Preview the Spark Messages Wiki for visual reference of Spark output and examples.
h1(text), h2(text), h3(text), h4(text), h5(text), h6(text)
Type: string
Text to be a header.
Alias: a(), anchor()
Type: string
Url for the link
Type: string
Mask for the link.
Type: string
Email address to create an link email. HTML equivalent = <a href="mailto:emailaddress">emailAddress</a>
Type: string
Mask for the email.
Alias: tel()
Type: string
Telephone number to be an tel:
.
Type: string
Mask for the telephone number.
Alias: ul(items)
Type: array
List of items to be individually transformed to unordered list items.
Alias: ol(items)
Type: array
List of items to be individually transformed to unordered list items.
Alias: ul(items)
Type: array
List of items to be individually transformed to ordered list items.
Alias: b(), heavy()
Type: string
Text to be bolded.
Alias: i(text), em(text), emphasis(text)
Type: string
Text to be italicize.
Alias: c(text)
Type: string
Text to be transformed into a code style.
Alias: cb(text)
Type: string
Text to be transformed into a code block style.
Alias: hr()
Returns a markdown horziontal rule (___).
Alias: br()
Returns a linebreak.
MIT Β© Brandon Him