nonplain/nonplain-md-backlinker.js

Improve context code with MagicString

jaredgorski opened this issue · 1 comments

This library will outsource the complex link replacement code: https://github.com/rich-harris/magic-string

OR, I can just implement the right algorithm: walk the content backward so that I don't mess up "future" index values when replacing the links

MagicString's overwrite method would be used for this. Currently, I'm replacing by regex. Instead, I would need to get start and end indices for each match of regex.links.all and feed those to the overwrite method on a loop. Then, I could use toString on each call to getWordsFromIndex.