Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brh55/spark-messages

:speech_balloon: A collection of helpers to ensure consistent, predictable formatting of Cisco spark markdown messages
https://github.com/brh55/spark-messages

Last synced: about 1 month ago
JSON representation

:speech_balloon: A collection of helpers to ensure consistent, predictable formatting of Cisco spark markdown messages

Awesome Lists containing this project

README

        

# spark-messages [![Build Status](https://img.shields.io/travis/brh55/spark-messages.svg?style=flat-square)](https://travis-ci.org/brh55/spark-messages) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square)](https://github.com/sindresorhus/xo)

> 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

```js
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
```js
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. ****
// 2. ****
// 3. ****
```

## API

Preview the [Spark Messages Wiki](https://github.com/brh55/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 = `emailAddress`

#### 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](https://github.com/brh55)