tellegram 1.1.3 → 1.1.4

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/lib/paginate.mjs CHANGED
@@ -12,7 +12,7 @@ const trim = (str, opts) => ensureString(str, { trim: true, ...opts || {} });
12
12
  // Is
13
13
  const _is = (type, value) => value?.constructor === type;
14
14
  const _type = (any) => typeof any === 'undefined' ? 'Undefined'
15
- : Object.prototype.toString.call(any).replace(/^\[[^\ ]*\ (.*)\]$/, '$1');
15
+ : Object.prototype.toString.call(any).replace(/^\[[^ ]* (.*)\]$/, '$1');
16
16
  [
17
17
  ArrayBuffer, BigInt, Boolean, Error, Number, Object, Set, String, Uint8Array
18
18
  ].map(type => {
@@ -88,14 +88,18 @@ export default (message, options) => {
88
88
  nextN === -1 && (nextN = message.length); // 剩下只有一行
89
89
  let cut = nextN; // 初始化當前預測裁切
90
90
  if (countLength(cut) > size && page.length) { submit(); continue; }
91
- let high = Math.min(cut, size);
92
- cut = 0;
93
- while (cut < high) {
94
- let mid = Math.ceil((cut + high) / 2);
95
- if (countLength(mid) <= size) {
96
- cut = mid;
97
- } else {
98
- high = mid - 1;
91
+ // cut = Math.min(cut, size);
92
+ // while (countLength(cut) > size) { cut--; }
93
+ if (countLength(cut) > size) {
94
+ let high = Math.min(cut, size);
95
+ cut = 0;
96
+ while (cut < high) {
97
+ let mid = Math.ceil((cut + high) / 2);
98
+ if (countLength(mid) <= size) {
99
+ cut = mid;
100
+ } else {
101
+ high = mid - 1;
102
+ }
99
103
  }
100
104
  }
101
105
  concat = cut < nextN ? '...' : '';
package/lib/tellegram.mjs CHANGED
@@ -136,7 +136,7 @@ const createHandlers = (definitions, unsupportedTagsStrategy) => ({
136
136
  processUnsupportedTags(defaultHandlers.html(node, _parent, context), unsupportedTagsStrategy),
137
137
  table: (node, _parent, context) =>
138
138
  processUnsupportedTags(gfmTableToMarkdown().handlers.table(node, _parent, context), unsupportedTagsStrategy),
139
- thematicBreak: (_node, _parent, _context) =>
139
+ thematicBreak: () =>
140
140
  processUnsupportedTags('---', unsupportedTagsStrategy),
141
141
  });
142
142
 
package/lib/utils.mjs CHANGED
@@ -31,7 +31,7 @@ export function escapeSymbols(text, textType = 'text') {
31
31
  .replace(/\(/g, '\\(')
32
32
  .replace(/\)/g, '\\)')
33
33
  case 'ignore_escaped':
34
- return text.replace(/(\\.)|([_*\[\]()~`>#+\-=|{}.!])/g, (match, escaped, char) => {
34
+ return text.replace(/(\\.)|([_*[\]()~`>#+\-=|{}.!])/g, (match, escaped, char) => {
35
35
  if (escaped) {
36
36
  return escaped;
37
37
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "tellegram",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Convert LLM-generated markdown into Telegram-specific markdown (MarkdownV2)",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
7
7
  "scripts": {
8
8
  "test": "NODE_OPTIONS='--experimental-vm-modules --no-deprecation' npx jest --coverage --verbose",
9
- "lint": "eslint",
9
+ "lint": "eslint . --ext .js,.mjs",
10
10
  "semantic-release": "semantic-release",
11
11
  "prepare": "husky install",
12
12
  "codecov": "codecov"
@@ -61,11 +61,11 @@
61
61
  "semantic-release": "^17.4.2"
62
62
  },
63
63
  "lint-staged": {
64
- "*.{js,json,md}": [
64
+ "*.{js,mjs,json,md}": [
65
65
  "prettier --write",
66
66
  "git add"
67
67
  ],
68
68
  "*.{css,scss,less}": "stylelint --fix",
69
- "*.js": "eslint --cache --fix"
69
+ "*.{js,mjs}": "eslint --cache --fix"
70
70
  }
71
71
  }