Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattmezza/msgdown
*Simple* /messages/, _formatted_.
https://github.com/mattmezza/msgdown
bold chat code emphasis formatter html italic strikethrough sub sup
Last synced: 9 days ago
JSON representation
*Simple* /messages/, _formatted_.
- Host: GitHub
- URL: https://github.com/mattmezza/msgdown
- Owner: mattmezza
- License: mit
- Created: 2018-11-20T10:52:52.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-15T13:35:05.000Z (about 1 year ago)
- Last Synced: 2024-10-11T07:09:48.227Z (25 days ago)
- Topics: bold, chat, code, emphasis, formatter, html, italic, strikethrough, sub, sup
- Language: JavaScript
- Homepage:
- Size: 136 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
msgdown
======A simple message formatter for bold, strikethrough, underline, sub, sup, italic and code.
![msgdown](https://img.shields.io/travis/mattmezza/msgdown.svg?style=for-the-badge)
![logo](https://github.com/mattmezza/msgdown/blob/master/logo.png)
### Installation
`yarn add msgdown`
### Usage
```js
const down = require('msgdown')const msg = `*Attention:* /msgdown/^TM^ is great¡1¡. _Use it_ or ~don\'t~ it is \`console.log('up to you!')\``
const html = down(msg)
````html` will contain exactly this:
```html
Attention: msgdownTM is great1. Use it ordon\'tit isconsole.log('up to you!')
```#### Custom tokens
By default `msgdown` will use these tokens:
```js
const defaultTokens = {
bold: {delimiter: '*', tag: 'strong'},
italic: {delimiter: '/', tag: 'em'},
underline: {delimiter: '_', tag: 'u'},
strike: {delimiter: '~', tag: 'del'},
code: {delimiter: '`', tag: 'code'},
sup: {delimiter: '^', tag: 'sup'},
sub: {delimiter: '¡', tag: 'sub'}
}
```You can override every and each of the tokens by passing in your custom token object on every function call:
```js
const html = down('ßI am bold with a bß', {bold: {delmiter: 'ß', tag: 'b'}})
```The above `html` will contain `I am bold with a b`.
### Testing
There is a test file linked to `yarn test`. Should be enough even though enough is never enough.
### Development
Maybe add more tokens? Maybe add pattern matching instead of plain one char matching? Maybe something else? You name it...
### Author
Matteo Merola