Skip to content

Commit

Permalink
Add plain URLs to targets mrjackphil#6
Browse files Browse the repository at this point in the history
  • Loading branch information
tadashi-aikawa committed Jan 30, 2021
1 parent 91ff8ec commit 31f8e4f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export default class JumpToLink extends Plugin {
const regExInternal = /\[\[(.+?)(\|.+?)?\]\]/g;
// expecting [Title](link)
const regExExternal = /\[.+?\]\((.+?)\)/g;
// expecting http://hogehoge or https://hogehoge
const regExUrl = /(?<= |\n|^)(https?:\/\/[^ \n]+)/g;

const strs = cmEditor.getValue();

Expand All @@ -230,12 +232,17 @@ export default class JumpToLink extends Plugin {
const linkText = regExResult[1];
linksWithIndex.push({ index: regExResult.index, type: 'internal', linkText });
}

while(regExResult = regExExternal.exec(strs)) {
const linkText = regExResult[1];
linksWithIndex.push({ index: regExResult.index, type: 'external', linkText })
}

while(regExResult = regExUrl.exec(strs)) {
const linkText = regExResult[1];
linksWithIndex.push({ index: regExResult.index, type: 'external', linkText })
}

const linkHintLetters = this.getLinkHintLetters(linksWithIndex.length);

const linksWithLetter: SourceLinkHint[] = [];
Expand Down

0 comments on commit 31f8e4f

Please sign in to comment.