@ai-matrx/records 0.94.1 → 0.95.1

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
@@ -1,5 +1,18 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.95.1
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records/v0.95.0..npm/records/v0.95.1 -- apps/shared/records`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.95.0 — a table exports as Markdown (lane FORMULA-2)
10
+
11
+ - **`exportMarkdown(fields, rows)`** (`@ai-matrx/records/core`): the same header and cells as `exportCsv` / `exportXlsx` (one cell
12
+ writer, `toAoa`), written as a pipe table. A `|` in a cell is escaped, a line break becomes `<br>`, no columns is no table.
13
+ - Tests: `a-table-exports-as-a-markdown-table.test.ts`.
14
+ - **Consumer action:** none. `@ai-matrx/records-ui` uses it for "Download Markdown" / "Copy as Markdown".
15
+
3
16
  ## 0.94.1
4
17
 
5
18
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -171,6 +171,7 @@ __export(core_exports, {
171
171
  err: () => err,
172
172
  exportCellText: () => exportCellText2,
173
173
  exportCsv: () => exportCsv,
174
+ exportMarkdown: () => exportMarkdown,
174
175
  exportPageXlsx: () => exportPageXlsx,
175
176
  exportXlsx: () => exportXlsx,
176
177
  fieldDeclarationFor: () => fieldDeclarationFor,
@@ -10697,6 +10698,13 @@ function headerFor(field) {
10697
10698
  function exportCsv(fields, rows2) {
10698
10699
  return (0, import_delimited.toDelimited)(toAoa(fields, rows2));
10699
10700
  }
10701
+ function exportMarkdown(fields, rows2) {
10702
+ if (fields.length === 0) return "";
10703
+ const cell = (text2) => text2.replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>").trim();
10704
+ const [head, ...body] = toAoa(fields, rows2);
10705
+ const line = (cells) => `| ${cells.map(cell).join(" | ")} |`;
10706
+ return [line(head ?? []), `| ${fields.map(() => "---").join(" | ")} |`, ...body.map(line)].join("\n") + "\n";
10707
+ }
10700
10708
  function toAoa(fields, rows2) {
10701
10709
  return [fields.map(headerFor), ...rows2.map((row) => fields.map((f) => exportCellText2(f, row[f.key])))];
10702
10710
  }