@noobdemon/noob-cli 1.12.2 → 1.12.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Tất cả thay đổi đáng kể của `@noobdemon/noob-cli` được ghi vào file này.
4
4
 
5
+ ## [1.12.3] - 2026-06-12
6
+
7
+ ### Fixed
8
+ - **Bảng markdown không render khi user paste có indent** (`src/ui.js`): `renderMarkdown` cũ pass thẳng input qua `marked.parse()` — nếu mọi dòng bị indent ≥4 space (case thường gặp khi copy/paste từ list item hoặc reply), CommonMark treat là indented code block → bảng/heading/list không parse, in ra dạng raw pipe `| A | B |`. Fix: thêm hàm `dedent(md)` strip common leading whitespace từ mọi dòng non-empty TRƯỚC khi gọi `marked.parse()`. Đồng thời gỡ regex `.replace(/^ {4}(.*)$/gm, '▎ ')` trong `prettify` — handler cũ cho code-block-by-indent, dư thừa (marked đã render code fence riêng) và còn nuốt nhầm dòng output bảng nếu lọt qua. Verify: bảng indent 2/4 space + bảng giữa prose + regression heading/list/code fence/blockquote đều OK.
9
+
5
10
  ## [1.12.2] - 2026-06-12
6
11
 
7
12
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noobdemon/noob-cli",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/ui.js CHANGED
@@ -148,14 +148,32 @@ export function renderBulletPrefix(line) {
148
148
  function prettify(s) {
149
149
  return s
150
150
  .replace(/^( *)\* /gm, (_, sp) => sp + BULLET + ' ')
151
- .replace(/^ {4}(.*)$/gm, (_, rest) => c.dim('▎ ') + rest)
152
151
  .split('\n')
153
152
  .map(renderInline)
154
153
  .join('\n');
155
154
  }
156
155
 
156
+ // Strip common leading whitespace từ mọi dòng non-empty. Cần thiết vì user hay
157
+ // paste markdown bị indent (vd copy từ list item, từ code block) → CommonMark
158
+ // treat indent ≥4 space là code block → bảng/heading/list không parse.
159
+ function dedent(md) {
160
+ if (!md) return md;
161
+ const lines = md.split('\n');
162
+ let min = Infinity;
163
+ for (const line of lines) {
164
+ if (!line.trim()) continue;
165
+ const m = line.match(/^( *)/);
166
+ const indent = m ? m[1].length : 0;
167
+ if (indent < min) min = indent;
168
+ if (min === 0) break;
169
+ }
170
+ if (!Number.isFinite(min) || min === 0) return md;
171
+ const re = new RegExp(`^ {${min}}`, 'gm');
172
+ return md.replace(re, '');
173
+ }
174
+
157
175
  export function renderMarkdown(md) {
158
- return prettify(marked.parse(md || '')).trimEnd();
176
+ return prettify(marked.parse(dedent(md || ''))).trimEnd();
159
177
  }
160
178
 
161
179
  // ── formatQuota ────────────────────────────────────────────────────────────