Skip to content

Commit 6084abc

Browse files
committed
Removed unecessary code, and updated some variables.
1 parent 44c95c0 commit 6084abc

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

main.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@ import { App, Plugin, MarkdownPostProcessor, MarkdownPostProcessorContext } from
33
export default class LinkHeadersDirectly extends Plugin {
44

55
async onload() {
6-
let postProc: MarkdownPostProcessor;
6+
7+
let postProc: MarkdownPostProcessor;
78

89
postProc = (el: HTMLElement, ctx: MarkdownPostProcessorContext) => {
910

10-
var linkElements = el.querySelectorAll('a.internal-link');
11-
var barIndex, alias;
12-
for(var i = 0; i < linkElements.length; i++) {
13-
barIndex = (linkElements[i] as HTMLElement).innerText.indexOf(">");
14-
if(barIndex < 0) continue;
15-
alias = (linkElements[i] as HTMLElement).innerText.substr(barIndex+2);
16-
(linkElements[i] as HTMLElement).innerText = alias;
17-
}
11+
let linkElements = el.querySelectorAll('a.internal-link');
12+
let barIndex, alias;
1813

19-
}
14+
for(var i = 0; i < linkElements.length; i++) {
2015

21-
this.registerMarkdownPostProcessor(postProc);
22-
}
16+
let linkAsHTML = (linkElements[i] as HTMLElement).innerText;
2317

24-
onunload() {
25-
console.log('unloading plugin');
18+
barIndex = linkAsHTML.indexOf(">");
19+
if(barIndex < 0) continue;
20+
alias = linkAsHTML.substr(barIndex+2);
21+
(linkElements[i] as HTMLElement).innerText = alias;
22+
}
23+
}
24+
this.registerMarkdownPostProcessor(postProc);
2625
}
2726
}

0 commit comments

Comments
 (0)