markdown-to-slack-blocks 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +205 -125
- package/dist/splitter.d.ts +5 -1
- package/dist/splitter.d.ts.map +1 -1
- package/dist/splitter.js +96 -78
- package/dist/types.d.ts +31 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/validator.d.ts +1 -1
- package/dist/validator.d.ts.map +1 -1
- package/package.json +61 -57
package/README.md
CHANGED
|
@@ -168,3 +168,16 @@ splitBlocksWithText(blocks, { maxBlocks: 40, maxCharacters: 12000 });
|
|
|
168
168
|
```
|
|
169
169
|
|
|
170
170
|
Splitting happens at natural boundaries: between blocks first, then within `rich_text` elements, and finally within large code blocks by line. `splitBlocksWithText` additionally generates a concise plaintext summary per batch (headers, sections, rich text, tables, etc.) suitable for Slack's `text` field.
|
|
171
|
+
|
|
172
|
+
### Plain text rendering
|
|
173
|
+
|
|
174
|
+
If you already have a block array and need a lightweight plaintext fallback (for example to populate the `text` field in `chat.postMessage`), use `blocksToPlainText`:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { blocksToPlainText } from 'markdown-to-slack-blocks';
|
|
178
|
+
|
|
179
|
+
const text = blocksToPlainText(blocks);
|
|
180
|
+
// -> "Hello world" or similar, depending on your blocks
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The function walks the rendered blocks and returns a joined string that keeps list markers, quotes, tables (as `cell | cell` rows), mentions, dates (using the provided fallback or ISO string), and basic formatting markers where possible. The output is best-effort and is intended for concise fallbacks rather than full fidelity rendering.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MarkdownToBlocksOptions } from
|
|
2
|
-
export * from
|
|
3
|
-
export { splitBlocks, splitBlocksWithText, SplitBlocksOptions, SplitBlocksResult } from
|
|
1
|
+
import type { MarkdownToBlocksOptions } from "./types";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export { blocksToPlainText, splitBlocks, splitBlocksWithText, SplitBlocksOptions, SplitBlocksResult, } from "./splitter";
|
|
4
4
|
export declare function markdownToBlocks(markdown: string, options?: MarkdownToBlocksOptions): import("./types").Block[];
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIvD,cAAc,SAAS,CAAC;AACxB,OAAO,EACN,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,uBAAuB,6BAIjC"}
|
package/dist/index.js
CHANGED
|
@@ -14,13 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.splitBlocksWithText = exports.splitBlocks = void 0;
|
|
17
|
+
exports.splitBlocksWithText = exports.splitBlocks = exports.blocksToPlainText = void 0;
|
|
18
18
|
exports.markdownToBlocks = markdownToBlocks;
|
|
19
19
|
const parser_1 = require("./parser");
|
|
20
20
|
const validator_1 = require("./validator");
|
|
21
21
|
// Re-export types for consumers
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
23
|
var splitter_1 = require("./splitter");
|
|
24
|
+
Object.defineProperty(exports, "blocksToPlainText", { enumerable: true, get: function () { return splitter_1.blocksToPlainText; } });
|
|
24
25
|
Object.defineProperty(exports, "splitBlocks", { enumerable: true, get: function () { return splitter_1.splitBlocks; } });
|
|
25
26
|
Object.defineProperty(exports, "splitBlocksWithText", { enumerable: true, get: function () { return splitter_1.splitBlocksWithText; } });
|
|
26
27
|
function markdownToBlocks(markdown, options) {
|
package/dist/parser.d.ts
CHANGED
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,KAAK,EAKL,uBAAuB,EAGvB,MAAM,SAAS,CAAC;AAmFjB,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,uBAA4B,GACnC,KAAK,EAAE,CAiNT"}
|