2024-02-21 16:27:54 -03:00
|
|
|
<!--header-->
|
|
|
|
|
|
|
|
|
|
<p align="center">
|
|
|
|
|
<a href="https://rocket.chat" title="Rocket.Chat">
|
|
|
|
|
<img src="https://github.com/RocketChat/Rocket.Chat.Artwork/raw/master/Logos/2020/png/logo-horizontal-red.png" alt="Rocket.Chat" />
|
|
|
|
|
</a>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
# `@rocket.chat/message-parser`
|
|
|
|
|
|
|
|
|
|
> Rocket.Chat parser for messages
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
[](https://www.npmjs.com/package/@rocket.chat/message-parser/v/latest) [](https://www.npmjs.com/package/@rocket.chat/message-parser/v/next)  
|
|
|
|
|
|
|
|
|
|
 
|
|
|
|
|
|
|
|
|
|
<!--/header-->
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
|
|
Rocket.Chat grammar with the purpose of parsing the messages of the rocket chat, converting text to an AST tree.
|
|
|
|
|
|
|
|
|
|
The grammar provides support for markdown, mentions and emojis.
|
|
|
|
|
|
|
|
|
|
## Supported markup
|
|
|
|
|
|
|
|
|
|
- quotes
|
|
|
|
|
- bold/italic/strike
|
|
|
|
|
- ordered lists
|
|
|
|
|
- unordered lists
|
|
|
|
|
- task lists
|
|
|
|
|
- phone numbers
|
|
|
|
|
- mentions
|
|
|
|
|
- emoji
|
|
|
|
|
- colors
|
|
|
|
|
- URI's
|
|
|
|
|
- mentions users/channels
|
2024-03-08 20:51:43 -03:00
|
|
|
- timestamps
|
|
|
|
|
|
|
|
|
|
## Timestamps
|
|
|
|
|
|
|
|
|
|
The timestamp tag is a special tag that allows you to convert a Unix timestamp to a human-readable date and time.
|
|
|
|
|
|
|
|
|
|
Timestamps are allowed inside strike elements.
|
|
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
|
|
Pattern: <t:{timestamp}:?{format}>
|
|
|
|
|
|
|
|
|
|
- {timestamp} is a Unix timestamp
|
|
|
|
|
- {format} is an optional parameter that can be used to customize the date and time format.
|
|
|
|
|
|
|
|
|
|
#### Formats
|
|
|
|
|
|
|
|
|
|
| Format | Description | Example |
|
|
|
|
|
| ------ | ------------------------- | --------------------------------------- |
|
|
|
|
|
| `t` | Short time | 12:00 AM |
|
|
|
|
|
| `T` | Long time | 12:00:00 AM |
|
|
|
|
|
| `d` | Short date | 12/31/2020 |
|
|
|
|
|
| `D` | Long date | Thursday, December 31, 2020 |
|
|
|
|
|
| `f` | Full date and time | Thursday, December 31, 2020 12:00 AM |
|
|
|
|
|
| `F` | Full date and time (long) | Thursday, December 31, 2020 12:00:00 AM |
|
|
|
|
|
| `R` | Relative time | 1 year ago |
|
2024-02-21 16:27:54 -03:00
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
<!--contributing(msg)-->
|
|
|
|
|
|
|
|
|
|
Contributions, issues, and feature requests are welcome!<br />
|
|
|
|
|
Feel free to check the [issues](https://github.com/RocketChat/fuselage/issues).
|
|
|
|
|
|
|
|
|
|
<!--/contributing(msg)-->
|
|
|
|
|
|
|
|
|
|
Whenever you find a grammar-related bug, start by inserting the test case.
|
|
|
|
|
|
|
|
|
|
We are open to other tags/markups, as long as they don't generate unexpected behavior.
|
|
|
|
|
|
|
|
|
|
## Observations and known issues
|
|
|
|
|
|
|
|
|
|
- Nested lists are unsupported
|
|
|
|
|
- `URL` rule doesn't allow whitespace, `(`, or `)`
|