Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-3282]): flag a markdown table as markup loss so its Show more renders

[._.]/ Adam Eivya4d63e1aa1f9
diff --git a/client/src/utils/markdownText.js b/client/src/utils/markdownText.js
index 4a6fdb1639..e66fb3fd03 100644
--- a/client/src/utils/markdownText.js
+++ b/client/src/utils/markdownText.js
@@ -16,6 +16,10 @@
// Fenced code blocks — keep the code, drop the fence lines (and any info string).
const FENCE_LINE = /^\s*(?:`{3,}|~{3,}).*$/;
+// A pipe-delimited table row, e.g. `| a | b |`. Used only by the
+// markup-loss predicate — see the note on `dropsMarkupWhenFlattened`.
+const TABLE_ROW = /^[ \t]*\|.*\|[ \t]*$/m;
+
// The whitespace tail both exports share. Kept as one function so the
// "did the flatten drop markup?" predicate below can subtract exactly the
// whitespace normalization `markdownToPlainText` performs — no more, no less.
@@ -93,8 +97,14 @@ export function markdownToPlainText(markdown) {
* comparing raw source to flattened output flags every trailing newline and
* double space, putting a "Show more" that reveals nothing on the most common
* short-body shape, on a page whose whole purpose is removing queue noise.
+ *
+ * Tables need their own probe: the flattener leaves pipe rows alone (and the
+ * `| --- |` separator escapes the thematic-break rule because it starts with a
+ * pipe), so a table flattens to itself and the diff below sees no loss — while
+ * the preview shows raw pipe soup with no route to the rendered table.
*/
export function dropsMarkupWhenFlattened(markdown) {
if (typeof markdown !== 'string' || !markdown) return false;
+ if (TABLE_ROW.test(markdown)) return true;
return markdownToPlainText(markdown) !== collapseWhitespace(markdown.replace(/\r\n?/g, '\n'));
}
diff --git a/client/src/utils/markdownText.test.js b/client/src/utils/markdownText.test.js
index 8283c32377..fdd62e6fb3 100644
--- a/client/src/utils/markdownText.test.js
+++ b/client/src/utils/markdownText.test.js
@@ -138,6 +138,15 @@ describe('dropsMarkupWhenFlattened', () => {
expect(dropsMarkupWhenFlattened('```\ncode\n```')).toBe(true);
});
+ it('is true for a table, which flattens to itself', () => {
+ // The flattener leaves pipe rows alone and the `| --- |` separator escapes
+ // the thematic-break rule, so the whitespace diff sees no loss — yet the
+ // preview is raw pipe soup that needs a route to the rendered table.
+ expect(dropsMarkupWhenFlattened('| a | b |\n| --- | --- |\n| c | d |')).toBe(true);
+ // A sentence that merely contains a pipe is not a table row.
+ expect(dropsMarkupWhenFlattened('run a | b to pipe it')).toBe(false);
+ });
+
it('is false for non-string / empty input', () => {
expect(dropsMarkupWhenFlattened(undefined)).toBe(false);
expect(dropsMarkupWhenFlattened(null)).toBe(false);