tellegram 1.1.4 → 1.1.6
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 +6 -8
- package/lib/paginate.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://codecov.io/gh/leask/tellegram)
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
teLLegraM is a library designed to format LLM (Large Language Model) generated text into [Telegram-specific-markdown (MarkdownV2)](https://core.telegram.org/bots/api#formatting-options), based on [Unified](https://github.com/unifiedjs/unified) and [Remark](https://github.com/remarkjs/remark/). It ensures that complex markdown from AI responses is perfectly interpreted by Telegram clients.
|
|
7
|
+
teLLegraM is a library designed to format LLM (Large Language Model) generated text into [Telegram-specific-markdown (MarkdownV2)](https://core.telegram.org/bots/api#formatting-options), based on [Unified](https://github.com/unifiedjs/unified) and [Remark](https://github.com/remarkjs/remark/). It ensures that complex markdown from AI responses is perfectly interpreted by Telegram clients. teLLegraM also supports a syntax-aware and lossless Markdown pagination.
|
|
8
8
|
|
|
9
9
|
## Acknowledgements
|
|
10
10
|
|
|
@@ -29,9 +29,7 @@ npm install tellegram
|
|
|
29
29
|
### Basic Conversion
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
|
-
import
|
|
33
|
-
// OR
|
|
34
|
-
// import { convert } from 'tellegram';
|
|
32
|
+
import { convert } from 'tellegram';
|
|
35
33
|
|
|
36
34
|
const markdown = `
|
|
37
35
|
# Header
|
|
@@ -46,7 +44,7 @@ const markdown = `
|
|
|
46
44
|
And simple text with + some - symbols.
|
|
47
45
|
`;
|
|
48
46
|
|
|
49
|
-
const result =
|
|
47
|
+
const result = convert(markdown);
|
|
50
48
|
console.log(result);
|
|
51
49
|
/*
|
|
52
50
|
*Header*
|
|
@@ -89,7 +87,7 @@ You can also add unsupported tags strategy as a second argument, which can be on
|
|
|
89
87
|
- `keep` - ignore unsupported tags
|
|
90
88
|
|
|
91
89
|
```js
|
|
92
|
-
|
|
90
|
+
import { convert } from 'tellegram';
|
|
93
91
|
const markdown = `
|
|
94
92
|
# Header
|
|
95
93
|
|
|
@@ -98,7 +96,7 @@ const markdown = `
|
|
|
98
96
|
<div>Text in div</div>
|
|
99
97
|
`;
|
|
100
98
|
|
|
101
|
-
|
|
99
|
+
convert(markdown, 'escape');
|
|
102
100
|
/*
|
|
103
101
|
*Header*
|
|
104
102
|
|
|
@@ -107,7 +105,7 @@ teLLegraM(markdown, 'escape');
|
|
|
107
105
|
<div\>Text in div</div\>
|
|
108
106
|
*/
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
convert(markdown, 'remove');
|
|
111
109
|
/*
|
|
112
110
|
*Header*
|
|
113
111
|
*/
|
package/lib/paginate.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
import convert from './convert.mjs';
|
|
3
3
|
|
|
4
|
-
const MESSAGE_LENGTH_LIMIT = parseInt(4096 * 0.
|
|
4
|
+
const MESSAGE_LENGTH_LIMIT = parseInt(4096 * 0.9); // ~= 3680
|
|
5
5
|
const clarify = str => str.toLowerCase().split(/[^a-zA-Z0-9]+/).filter(x => x);
|
|
6
6
|
const lines = (arr, sep = '\n') => arr.join(sep);
|
|
7
7
|
const extError = (err, status, opt = {}) => Object.assign(err, { status }, opt);
|