tellegram 1.1.10 → 1.1.11

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 CHANGED
@@ -119,9 +119,9 @@ convert(markdown, 'remove');
119
119
  ### Convert tables to list
120
120
 
121
121
  Telegram does not support Markdown tables. By default, teLLegraM converts a
122
- table into a vertical hierarchical list. In this mode, the first column is
123
- rendered as a title-like line, and following fields are rendered as escaped
124
- `-` list lines to stay safe for Telegram MarkdownV2.
122
+ table into a vertical hierarchical list using one numbered title line per row
123
+ plus `-` lines for the remaining fields. Number markers and `-` markers are
124
+ escaped to stay safe for Telegram MarkdownV2.
125
125
 
126
126
  ```js
127
127
  import { convert } from 'tellegram';
@@ -135,11 +135,11 @@ const markdown = `
135
135
 
136
136
  convert(markdown, 'escape');
137
137
  /*
138
- *Name:* Alice
138
+ 1\. Name: Alice
139
139
  \- Role: Admin
140
140
  \- Score: 95
141
141
 
142
- *Name:* Bob
142
+ 2\. Name: Bob
143
143
  \- Role: User
144
144
  \- Score: 88
145
145
  */
@@ -24,12 +24,12 @@ const normalizeValue = (cell, context) => {
24
24
  return value || EMPTY_VALUE;
25
25
  };
26
26
 
27
- const pairToLine = (pair, isNested) => {
28
- if (!isNested) {
29
- return `*${pair.header}:* ${pair.value}`;
27
+ const pairToLine = (pair, rowIndex, isNested) => {
28
+ if (isNested) {
29
+ return `\\- ${pair.header}: ${pair.value}`;
30
30
  }
31
31
 
32
- return `\\- ${pair.header}: ${pair.value}`;
32
+ return `${rowIndex + 1}\\. ${pair.header}: ${pair.value}`;
33
33
  };
34
34
 
35
35
  export default (node, context) => {
@@ -55,13 +55,13 @@ export default (node, context) => {
55
55
  });
56
56
 
57
57
  if (!pairs.length) {
58
- return `*Item ${rowIndex + 1}:* ${EMPTY_VALUE}`;
58
+ return `${rowIndex + 1}\\. Item ${rowIndex + 1}: ${EMPTY_VALUE}`;
59
59
  }
60
60
 
61
61
  const [first, ...rest] = pairs;
62
62
  return [
63
- pairToLine(first, false),
64
- ...rest.map(pair => pairToLine(pair, true)),
63
+ pairToLine(first, rowIndex, false),
64
+ ...rest.map(pair => pairToLine(pair, rowIndex, true)),
65
65
  ].join('\n');
66
66
  });
67
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tellegram",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "Convert LLM-generated markdown into Telegram-specific markdown (MarkdownV2)",
5
5
  "type": "module",
6
6
  "main": "index.mjs",