# Automatically replace special characters by escape characters in URI link

**URL:** <https://forum.obsidian.md/t/automatically-replace-special-characters-by-escape-characters-in-uri-link/79826>\
**Category:** Help\
**Tags:** templater\
**Created:** [April 4, 2024, 4:24pm UTC](https://forum.obsidian.md/t/automatically-replace-special-characters-by-escape-characters-in-uri-link/79826 "2024-04-04T16:24:20Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![gino\_m](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@gino\_m](https://forum.obsidian.md/u/gino_m)\
**Post date:** [April 4, 2024, 6:34pm UTC](https://forum.obsidian.md/t/automatically-replace-special-characters-by-escape-characters-in-uri-link/79826/4 "2024-04-04T18:34:32Z")

</div>

For now, I can only help with the structure of the Templater code. I cannot make time to look into all relevant character encodings or if they need double encoding, or ask about your operating system for treatment of slashes in the path, I’m afraid.

So your Templater script you can bind a hotkey to can look like this:

```auto
<%*
clipboard = (await tp.system.clipboard());
clipboard = clipboard.replace(/\s-\s/gm, " – ");
tR += clipboard;
_%>

```

In my trimmed example the `clipboard = clipboard.replace(/\s-\s/gi, " – ");` replaces dashes to n-dashes (when a dash is not a hyphen).  
You’ll need to populate all your rules here. The stupidest ChatGPT bot can help with this. Just make sure you prompt it with your exact requirements (specify OS for correct path).  
Feed it this snippet as well so the bots knows what to build its answers around.

When you fire the script, the changed content gets pasted in the editor with `tR +=`.

Also, there’s a great post about external links:

> [@Linking to external files & folders link](https://forum.obsidian.md/t/linking-to-external-files-folders/70121):
>
> Linking to external files is mentioned in the [drag and drop](https://help.obsidian.md/User+interface/Drag+and+Drop) help documentation Hold Ctrl on Windows/Linux or Option on macOS to create file:/// absolute links to those files instead of importing a copy. but there aren’t any examples of the options available. I’ll write up a request to add some examples to the official help documentation, but for the time being, here’s a list I’ve collected. Windows UPDATE: from Obsidian v1.5.11 on, use forward slashes in paths UPDATE2: Not sure when it ha…

---

_[View the full topic](https://forum.obsidian.md/t/automatically-replace-special-characters-by-escape-characters-in-uri-link/79826)._
