Skip to content

Commit

Permalink
feat(CSV Crumbs): ✨ Allow CSV items to be wikilinks (The secret is th…
Browse files Browse the repository at this point in the history
…at it doesn't have to be a CSV file! So using wikilinks allows the items to be auto updated) (fix #196)
  • Loading branch information
SkepticMystic committed Nov 25, 2021
1 parent 22d0b6f commit e1171c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23681,6 +23681,12 @@ function makeWiki(wikiQ, str) {
}
return copy;
}
function dropWikilinks(str) {
let copy = str.slice();
if (copy.startsWith("[[") && copy.endsWith("]]"))
copy = copy.slice(2, -2);
return copy;
}
/**
* Get all the fields in `dir`.
* Returns all fields if `dir === 'all'`
Expand Down Expand Up @@ -50090,10 +50096,11 @@ class BCPlugin extends require$$0.Plugin {
const rowObj = {};
row
.split(",")
.map((head) => head.trim())
.map((head) => dropWikilinks(head.trim()))
.forEach((item, i) => {
rowObj[headers[i]] = item;
});
loglevel.debug({ rowObj });
CSVRows.push(rowObj);
});
return CSVRows;
Expand Down
7 changes: 3 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
addEdgeIfNot,
addNodesIfNot,
getFieldInfo,
getInNeighbours,
getOppDir,
getOppFields,
getReflexiveClosure,
Expand All @@ -60,8 +59,7 @@ import type {
} from "./interfaces";
import {
createOrUpdateYaml,
// debugGroupEnd,
// debugGroupStart,
dropWikilinks,
getBaseFromPath,
getDVBasename,
getFields,
Expand Down Expand Up @@ -495,10 +493,11 @@ export default class BCPlugin extends Plugin {
const rowObj = {};
row
.split(",")
.map((head) => head.trim())
.map((head) => dropWikilinks(head.trim()))
.forEach((item, i) => {
rowObj[headers[i]] = item;
});
debug({ rowObj });
CSVRows.push(rowObj);
});
return CSVRows;
Expand Down
6 changes: 6 additions & 0 deletions src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ export function makeWiki(wikiQ: boolean, str: string) {
return copy;
}

export function dropWikilinks(str: string) {
let copy = str.slice();
if (copy.startsWith("[[") && copy.endsWith("]]")) copy = copy.slice(2, -2);
return copy;
}

/**
* Get all the fields in `dir`.
* Returns all fields if `dir === 'all'`
Expand Down

0 comments on commit e1171c5

Please sign in to comment.