Skip to content

Commit

Permalink
Merge pull request #930 from trey-wallis/dev
Browse files Browse the repository at this point in the history
8.15.12
  • Loading branch information
decaf-dev authored Feb 22, 2024
2 parents 5df0b6f + a1f8aff commit c31d679
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"fundingUrl": {
"Buymeacoffee": "https://www.buymeacoffee.com/treywallis"
},
"version": "8.15.11"
"version": "8.15.12"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-dataloom",
"version": "8.15.11",
"version": "8.15.12",
"description": "Weave together data from diverse sources into different views. Inspired by Excel Spreadsheets and Notion.so.",
"main": "main.js",
"scripts": {
Expand Down
17 changes: 11 additions & 6 deletions src/shared/export/export-to-markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ import { LoomState } from "../loom-state/types/loom-state";
import { markdownTable } from "markdown-table";
import { loomStateToArray } from "./loom-state-to-array";
import { App } from "obsidian";
import { escapePipeCharacters } from "./export-utils";
import {
escapePipeCharacters,
replaceNewLinesWithBreaks,
} from "./export-utils";

export const exportToMarkdown = (
app: App,
loomState: LoomState,
shouldRemoveMarkdown: boolean
): string => {
const arr = loomStateToArray(app, loomState, shouldRemoveMarkdown);
let arr = loomStateToArray(app, loomState, shouldRemoveMarkdown);

//Markdown table cells can't contain new lines, so we replace them with <br> tags
arr = arr.map((row) => row.map((cell) => replaceNewLinesWithBreaks(cell)));

//Markdown table cells can't contain pipe characters, so we escape them
//Obsidian will render the escaped pipe characters as normal pipe characters
const escapedArr = arr.map((row) =>
row.map((cell) => escapePipeCharacters(cell))
);
return markdownTable(escapedArr);
arr = arr.map((row) => row.map((cell) => escapePipeCharacters(cell)));
return markdownTable(arr);
};
3 changes: 3 additions & 0 deletions src/shared/export/export-utils.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export const escapePipeCharacters = (value: string) =>
value.replace(/\|/g, "\\|");

export const replaceNewLinesWithBreaks = (value: string) =>
value.replace(/\n/g, "<br>");
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@
"8.15.8": "1.4.0",
"8.15.9": "1.4.0",
"8.15.10": "1.4.0",
"8.15.11": "1.4.0"
"8.15.11": "1.4.0",
"8.15.12": "1.4.0"
}

0 comments on commit c31d679

Please sign in to comment.