Skip to content

Commit

Permalink
fix(Hierarchy Note): 🐛 Blanks line allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Aug 20, 2021
1 parent caa5426 commit 596bd64
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,28 @@ export default class BreadcrumbsPlugin extends Plugin {
}

hierarchyNoteAdjList = (str: string) => {
const layers = str.split("\n");
const layers = str.split("\n").filter((line) => line);
console.log({ layers });

const depth = (line: string) => line.split("-")[0].length;

const hier: { note: string; depth: number; children: string[] }[] = [];

const lineRegex = new RegExp(/\s*- \[\[(.*)\]\]/);

console.log({ str });
let lineNo = 0;
while (lineNo < layers.length) {
const currLine = layers[lineNo];
if (currLine === "") continue;

const currNote = currLine.match(lineRegex)[1];
const currDepth = depth(currLine);

hier[lineNo] = { note: currNote, depth: currDepth, children: [] };

if (lineNo !== layers.length - 1) {
const nextLine = layers[lineNo + 1];
console.log({ nextLine });
const nextNote = nextLine.match(lineRegex)[1];
const nextDepth = depth(nextLine);

Expand Down

0 comments on commit 596bd64

Please sign in to comment.