mgmeyers / obsidian-copy-block-link

Get links to blocks and headings from Obsidian's right click menu.
GNU General Public License v3.0
177 stars 10 forks source link

adding a regex when copying headings #15

Closed jenningsb2 closed 2 years ago

jenningsb2 commented 2 years ago

Fixes #13

mgmeyers commented 2 years ago

@jenningsb2 Thanks for this! I took a peak at the obsidian source and saw that Licat uses this regex and function to sanitize headers. Maybe to be safe we should use this regex? What do you think?

var pg = /[!"#$%&()*+,.:;<=>?@^`{|}~\/\[\]\\]/g;
function pA(t) {
            return pg.lastIndex = 0,
            t.replace(pg, " ").replace(/\s+/g, " ").trim()
}
jenningsb2 commented 2 years ago

That's a great idea! I should have thought to look for that!