slack-message-parser
Advanced tools
Comparing version 2.0.2 to 3.0.0
{ | ||
"module": "./esm/mod.js", | ||
"main": "./script/mod.js", | ||
"types": "./types/mod.d.ts", | ||
"name": "slack-message-parser", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Parser for Slack message", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "jest", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts'", | ||
"prepublishOnly": "npm run build", | ||
"docs": "vuepress dev docs", | ||
"docs:build": "vuepress build docs" | ||
}, | ||
"files": [ | ||
"lib", | ||
"docs/**/*.md" | ||
], | ||
"repository": { | ||
@@ -32,52 +21,23 @@ "type": "git", | ||
"homepage": "https://github.com/pocka/slack-message-parser#readme", | ||
"devDependencies": { | ||
"@types/jest": "^23.3.2", | ||
"husky": "^1.0.0-rc.14", | ||
"jest": "^23.6.0", | ||
"lint-staged": "^7.2.2", | ||
"prettier": "^1.14.2", | ||
"ts-jest": "^23.1.4", | ||
"tslint": "^5.11.0", | ||
"tslint-config-prettier": "^1.15.0", | ||
"typescript": "^4.2.4", | ||
"vuepress": "^1.2.0", | ||
"yarn": "^1.9.4" | ||
}, | ||
"sideEffects": false, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
"exports": { | ||
".": { | ||
"import": { | ||
"default": "./esm/mod.js", | ||
"types": "./types/mod.d.ts" | ||
}, | ||
"require": { | ||
"default": "./script/mod.js", | ||
"types": "./types/mod.d.ts" | ||
} | ||
} | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts", | ||
"!node_modules/**" | ||
], | ||
"coverageReporters": [ | ||
"lcov", | ||
"text" | ||
], | ||
"transform": { | ||
"^.+\\.ts?$": "ts-jest" | ||
}, | ||
"testRegex": "/tests/.*\\.spec\\.ts$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js", | ||
"json", | ||
"node" | ||
] | ||
"scripts": { | ||
"test": "node test_runner.js" | ||
}, | ||
"lint-staged": { | ||
"*.{ts,md}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true | ||
"devDependencies": { | ||
"@types/node": "16.11.37", | ||
"chalk": "4.1.2", | ||
"@deno/shim-deno": "~0.10.0" | ||
} | ||
} | ||
} |
# slack-message-parser | ||
[![npm](https://img.shields.io/github/package-json/v/pocka/slack-message-parser)](https://www.npmjs.com/package/slack-message-parser) | ||
[![npm](https://img.shields.io/npm/v/slack-message-parser)](https://www.npmjs.com/package/slack-message-parser) | ||
[![Lint Workflow Status](https://img.shields.io/github/workflow/status/pocka/slack-message-parser/Lint%20files?label=lint)](https://github.com/pocka/slack-message-parser/actions/workflows/lint.yml) | ||
@@ -15,2 +15,4 @@ [![Test Workflow Status](https://img.shields.io/github/workflow/status/pocka/slack-message-parser/Test%20and%20collect%20coverage?label=test)](https://github.com/pocka/slack-message-parser/actions/workflows/test.yml) | ||
Requires Node.js >=v16. | ||
```sh | ||
@@ -26,5 +28,5 @@ npm i --save slack-message-parser | ||
```ts | ||
import slackMessageParser, { Node, NodeType } from 'slack-message-parser' | ||
import slackMessageParser, { Node, NodeType } from "slack-message-parser"; | ||
const tree = slackMessageParser('Slack *message* ~to~ _parse_') | ||
const tree = slackMessageParser("Slack *message* ~to~ _parse_"); | ||
@@ -59,18 +61,18 @@ // tree is: | ||
case NodeType.Root: | ||
return `<p>${node.children.map(toHTML).join('')}</p>` | ||
return `<p>${node.children.map(toHTML).join("")}</p>`; | ||
case NodeType.Text: | ||
return node.text | ||
return node.text; | ||
case NodeType.Bold: | ||
return `<strong>${node.children.map(toHTML).join('')}</strong>` | ||
return `<strong>${node.children.map(toHTML).join("")}</strong>`; | ||
case NodeType.Italic: | ||
return `<i>${node.children.map(toHTML).join('')}</i>` | ||
return `<i>${node.children.map(toHTML).join("")}</i>`; | ||
case NodeType.Strike: | ||
return `<del>${node.children.map(toHTML).join('')}</del>` | ||
return `<del>${node.children.map(toHTML).join("")}</del>`; | ||
default: | ||
// You can use `source` property, which every nodes have, to serialize unknown nodes as-is | ||
return node.source | ||
return node.source; | ||
} | ||
} | ||
}; | ||
console.log(toHTML(tree)) | ||
console.log(toHTML(tree)); | ||
@@ -77,0 +79,0 @@ // Output: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44249
3
24
814
79
2