Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/brh55/spark-messages
- Owner: brh55
- License: mit
- Created: 2017-02-03T16:45:24.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-18T22:58:09.000Z (over 7 years ago)
- Last Synced: 2024-10-12T21:50:50.541Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 46.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome-webex - spark-messages - A collection of helpers to ensure consistent formatting of markdown messages (by brh55). (Code samples / REST API samples)
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)