diff --git a/src/components/molecules/RunContent.tsx b/src/components/molecules/RunContent.tsx
index ff414628e..30a38a1aa 100644
--- a/src/components/molecules/RunContent.tsx
+++ b/src/components/molecules/RunContent.tsx
@@ -48,7 +48,6 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
}
}, [row.serializableOutput]);
-
// Function to convert table data to CSV format
const convertToCSV = (data: any[], columns: string[]): string => {
const header = columns.join(',');
@@ -58,6 +57,29 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
return [header, ...rows].join('\n');
};
+
+ const convertToMarkdown = (data: any[], columns: string[]): string => {
+
+ const headerRow = `| ${columns.join(' | ')} |`;
+
+ // Create separator row for Markdown tables
+ const separatorRow = `| ${columns.map(() => '---').join(' | ')} |`;
+
+
+ const dataRows = data.map(row =>
+ `| ${columns.map(col => {
+
+ const value = row[col];
+ return value === undefined || value === "" ? "-" :
+
+ String(value).replace(/\|/g, '\\|').replace(/\n/g, ' ');
+ }).join(' | ')} |`
+ );
+
+
+ return [headerRow, separatorRow, ...dataRows].join('\n');
+ };
+
const downloadCSV = () => {
const csvContent = convertToCSV(tableData, columns);
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
@@ -71,6 +93,19 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
document.body.removeChild(link);
};
+ const downloadMarkdown = () => {
+ const markdownContent = convertToMarkdown(tableData, columns);
+ const blob = new Blob([markdownContent], { type: 'text/markdown;charset=utf-8;' });
+ const url = URL.createObjectURL(blob);
+
+ const link = document.createElement("a");
+ link.href = url;
+ link.setAttribute("download", "data.md");
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ };
+
return (
@@ -129,6 +164,11 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
>
Download as CSV
+
+ Download as Markdown
+
{tableData.length > 0 ? (
@@ -199,4 +239,4 @@ export const RunContent = ({ row, currentLog, interpretationInProgress, logEndRe
);
-};
+};
\ No newline at end of file