Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BurntCaramel/lofi-js
Format rich content using #hashtags and @mentions
https://github.com/BurntCaramel/lofi-js
content javascript nodejs parser text text-formatting
Last synced: about 1 month ago
JSON representation
Format rich content using #hashtags and @mentions
- Host: GitHub
- URL: https://github.com/BurntCaramel/lofi-js
- Owner: BurntCaramel
- Created: 2017-01-10T11:13:48.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-08T12:27:23.000Z (almost 8 years ago)
- Last Synced: 2024-12-02T08:21:09.714Z (about 2 months ago)
- Topics: content, javascript, nodejs, parser, text, text-formatting
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lofi · JavaScript
## Installation
```
npm install lofi --save
```## API Docs
### parseElement(input: String)
Element:
- texts: [ String ] · Array of plain text input
- mentions: [ [ String ] ] · Array of key paths
- tags: { String: Boolean | { texts: [ String ] , mentions: [ [ String ] ] } } · Key-value pairs of booleans or strings
- children: [ Element ] · Array of children elements```js
parseElement('Click me #button #primary')
/* => {
texts: ['Click me'],
mentions: [null],
tags: { button: true, primary: true },
children: []
} */parseElement('Hello @first-name, how are you?')
/* => {
texts: ['Hello ', ', how are you?'],
mentions: [['first-name'], null],
tags: {},
children: []
} */
```## Demos
- [Interactive demo of parseElement](http://codepen.io/burntcaramel/pen/apaKVL?editors=0010)