Skip to content

Commit

Permalink
Create correct Wiki Links
Browse files Browse the repository at this point in the history
Previous behavior created wrong Wiki links: [[Alt Link Text|Link]] instead of the correct [[Link|Alt Link Text]]
  • Loading branch information
lukaskawerau authored Sep 24, 2018
1 parent 7a90f79 commit aa7268c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/custom-markdown-it-features/wikilink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ export default (md: MarkdownIt, config: MarkdownEngineConfig) => {
}

const splits = content.split("|");
const linkText = splits[0].trim();
const wikiLink =
splits.length === 2
? `${splits[1].trim()}${config.wikiLinkFileExtension}`
: `${linkText.replace(/\s/g, "_")}${config.wikiLinkFileExtension}`;

return `<a href="${wikiLink}">${linkText}</a>`;
if (splits.length === 1) {
const wikiLink = `${splits[0].trim()}${config.wikiLinkFileExtension}`
const linkText = splits[0].trim();
return `<a href="${wikiLink}">${linkText}</a>`;
}
else {
const wikiLink = `${splits[0].trim()}${config.wikiLinkFileExtension}`
const linkText = splits[1].trim();
return `<a href="${wikiLink}">${linkText}</a>`;
}
};
};

0 comments on commit aa7268c

Please sign in to comment.