wkallhof / Hazel

Fast, simple, markdown powered wiki knowledge base for Node.js
http://hazel.wmk.io
GNU General Public License v3.0
118 stars 28 forks source link

Auto Linking only links first item in a document #17

Open MatthewCallis opened 6 years ago

MatthewCallis commented 6 years ago

https://github.com/wkallhof/Hazel/blob/a4b4ebc3f513fe3d6107652e50ede955134cc961/app/controllers/documentController.js#L106-L113

I updated this code to (but also moved to using slugify):

      missingLinks.forEach((link) => {
        const title = link.substr(1).slice(0, -3);
        const pairSlug = slugify(title, { lower: true });
        document.markdown = document.markdown.replace(link, `[${title}](/${pairSlug})`);
      });

Also needed to make this RegEx a global search:

https://github.com/wkallhof/Hazel/blob/a4b4ebc3f513fe3d6107652e50ede955134cc961/app/utilities/documentParserUtility.js#L13

this._missingLinkRegex = /\[(.*)\]\(\)/g;