-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: @rocket.chat/message-parser (#443)
Co-authored-by: Tasso Evangelista <[email protected]>
- Loading branch information
Showing
49 changed files
with
3,641 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
extends: '@rocket.chat/eslint-config-alt/minimal', | ||
env: { | ||
jest: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['**/*.ts', '**/*.tsx'], | ||
extends: '@rocket.chat/eslint-config-alt/typescript', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@rocket.chat/prettier-config/fuselage'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# @rocket.chat/message-parser | ||
|
||
## 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 | ||
|
||
## Contributing | ||
|
||
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/RocketChat/Rocket.Chat.Fuselage/issues). | ||
|
||
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 ` `, `(`, or `)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
browsers: [ | ||
'Chrome >= 59', | ||
'FireFox >= 44', | ||
'Safari >= 7', | ||
'Explorer 11', | ||
'last 4 Edge versions', | ||
], | ||
}, | ||
}, | ||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
coverageReporters: [], | ||
transform: { | ||
'\\.pegjs$': path.resolve(__dirname, './loaders/pegtransform.js'), | ||
}, | ||
preset: 'ts-jest', | ||
errorOnDeprecated: true, | ||
testMatch: ['<rootDir>/tests/**/*.(spec|test).ts'], | ||
moduleFileExtensions: ['js', 'ts', 'pegjs'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const pegjs = require('peggy'); | ||
|
||
module.exports = (content) => | ||
pegjs.generate(content, { | ||
output: 'source', | ||
format: 'commonjs', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const pegjs = require('peggy'); | ||
|
||
module.exports = { | ||
process: (content) => | ||
pegjs.generate(content, { | ||
output: 'source', | ||
format: 'commonjs', | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./dist/messageParser.production.js'); | ||
} else { | ||
module.exports = require('./dist/messageParser.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"name": "@rocket.chat/message-parser", | ||
"description": "Rocket.Chat parser for messages", | ||
"version": "0.23.0", | ||
"author": { | ||
"name": "Rocket.Chat", | ||
"url": "https://rocket.chat/" | ||
}, | ||
"license": "MIT", | ||
"homepage": "https://github.com/RocketChat/Rocket.Chat.Fuselage#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/RocketChat/Rocket.Chat.Fuselage.git", | ||
"directory": "packages/message-parser" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/RocketChat/Rocket.Chat.Fuselage/issues" | ||
}, | ||
"main": "messageParser.js", | ||
"exports": { | ||
".": { | ||
"default": "./messageParser.js" | ||
}, | ||
"./index": { | ||
"default": "./messageParser.js" | ||
} | ||
}, | ||
"module": "dist/messageParser.mjs", | ||
"unpkg": "dist/messageParser.umd.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"/dist", | ||
"/messageParser.js" | ||
], | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.14.0", | ||
"@babel/eslint-parser": "^7.13.14", | ||
"@babel/preset-env": "^7.14.1", | ||
"@rocket.chat/eslint-config-alt": "workspace:packages/eslint-config-alt", | ||
"@rocket.chat/prettier-config": "workspace:packages/prettier-config", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^14.14.43", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"babel-loader": "^8.2.2", | ||
"eslint": "^7.25.0", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"npm-run-all": "^4.1.5", | ||
"peggy": "^1.1.0", | ||
"prettier": "^2.2.1", | ||
"prettier-plugin-pegjs": "^0.3.2", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.5.5", | ||
"ts-loader": "^9.1.1", | ||
"typescript": "^4.2.4", | ||
"webpack": "^5.36.2", | ||
"webpack-cli": "^4.6.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"build": "run-s .:build:clean .:build:bundle", | ||
".:build:clean": "rimraf dist", | ||
".:build:bundle": "webpack", | ||
"test": "jest --runInBand --coverage", | ||
"watch": "jest --watch", | ||
"lint": "eslint .", | ||
"lint-fix": "run-p .:lint-fix:eslint .:lint-fix:prettier", | ||
".:lint-fix:eslint": "eslint --fix .", | ||
".:lint-fix:prettier": "prettier --write '**/*.pegjs'", | ||
"lint-staged": "lint-staged" | ||
} | ||
} |
Oops, something went wrong.