Skip to content

Commit

Permalink
Close #2 for wrong tabbing
Browse files Browse the repository at this point in the history
  • Loading branch information
LoyalPotato committed Aug 20, 2023
1 parent 8daaa15 commit 6a9769f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/indexSvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function generateIndex(content: string): string {
isNewIndex = true;
indexPos[0] = i + 1;
}
contents += `${generateLink(line)}\n`;
contents += `${generateLink(line, contents.length === 0 ? "" : undefined)}\n`;
}
}

Expand All @@ -40,11 +40,7 @@ export function generateIndex(content: string): string {
}


/**
* NOTE:
* One improvement we can do is, if it's a selection, that the tabs are handled as if the first title is # and increments, since we're replacing it for tabs
*/
function generateLink(header: string): string {
function generateLink(header: string, tabsOverride?: string): string {
let tabs = "";
let h = "";
let headerTitle = "";
Expand All @@ -61,6 +57,7 @@ function generateLink(header: string): string {

headerTitle = headerTitle.trim();
tabs = tabs.slice(0, -1);
if (tabsOverride != null) tabs = tabsOverride;

return `${tabs} - [${headerTitle}](${h}${headerTitle.replaceAll(" ", "%20")})`;
}

0 comments on commit 6a9769f

Please sign in to comment.