# How can I make obsidian to use commonmark links specification by default rather than wikilink?

**URL:** <https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565>\
**Category:** Help\
**Created:** [September 17, 2023, 5:19pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565 "2023-09-17T17:19:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![goahead97](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/b9e5f3/32.png) [@goahead97](https://forum.obsidian.md/u/goahead97)\
**Post date:** [September 17, 2023, 5:19pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/1 "2023-09-17T17:19:49Z")

</div>

First, search the [help docs](https://help.obsidian.md) and this forum. Maybe your question has been answered! The [debugging steps](https://forum.obsidian.md/t/about-the-bug-reports-category/24/11) can help, too. Still stuck? Delete this line and proceed.

### What I’m trying to do

I would like Obsidian to use commonmark specification by default when I copy and paste a picture or text file within a note.

### Things I have tried

Copying and pasting a picture or a text file within a note creates a wikilink instead of a link with the commonmark specification.

With commonmark specification I mean the third option described on  
[https://forum.obsidian.md/t/how-to-link-a-file-with-filename-with-spaces/22592/7](https://forum.obsidian.md/t/how-to-link-a-file-with-filename-with-spaces/22592/7)  
out of these:  
Wikilink 1. [[Test 2|this one]]  
Markdown 2. [this one] (Test%202)  
CommonMark 3. [this one] (\<Test 2\>)

Thanks

---

<div class="post-metadata">

**Author:** ![stef.rausch](https://forum.obsidian.md/user_avatar/forum.obsidian.md/stef.rausch/32/51207_2.png) [@stef.rausch](https://forum.obsidian.md/u/stef.rausch)\
**Post date:** [September 17, 2023, 9:45pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/2 "2023-09-17T21:45:33Z")

</div>

In “Files & Links” settings, have the `Use [[Wikilinks]]` option deactivated to generate Markdown links.

 ![image](https://forum.obsidian.md/uploads/default/original/3X/5/7/57637676e193c861839166eac2dc1cafd4ba6ede.png)

Regarding the specific option no. 3, you could use `Linter`’s “Custom Regex Replacement” feature to “fix” the missing `<>`.

---

<div class="post-metadata">

**Author:** ![goahead97](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/g/b9e5f3/32.png) [@goahead97](https://forum.obsidian.md/u/goahead97)\
**Post date:** [September 20, 2023, 3:43pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/3 "2023-09-20T15:43:01Z")

</div>

I just tried this:  
regex to find: ![(._)]([^\<\>]_)  
regex to replace: !([(._)])(\<(._)\>)

 ![image](https://forum.obsidian.md/uploads/default/original/3X/5/0/506ef7f713f747a506eb4408f841adedf8e527f0.png)

The current note has this link:  
![Pasted image 20230917184634.png](Pasted%20image%2020230917184634.png)

Saving the note to make Linter work updates the link and leaves it as dislpayed below:  
!([(._)])(\<(._)\>)

That means, Linter does not work as expected.

Do you know how to fix it?  
Thanks

---

<div class="post-metadata">

**Author:** ![stef.rausch](https://forum.obsidian.md/user_avatar/forum.obsidian.md/stef.rausch/32/51207_2.png) [@stef.rausch](https://forum.obsidian.md/u/stef.rausch)\
**Post date:** [September 20, 2023, 4:27pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/4 "2023-09-20T16:27:47Z")

</div>

Sure, `Linter` does work as expected: it just does what you tell it. 😉

The correct sequence is: `(!\[[^\]]+\]\()([^)]+)\)` + `gm` + `$1<$2>)`.

You need to capture the separate parts and then to “re-assemble” your way.

---

<div class="post-metadata">

**Author:** ![stef.rausch](https://forum.obsidian.md/user_avatar/forum.obsidian.md/stef.rausch/32/51207_2.png) [@stef.rausch](https://forum.obsidian.md/u/stef.rausch)\
**Post date:** [September 20, 2023, 4:37pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/5 "2023-09-20T16:37:53Z")

</div>

I just found out that the `<>` will be “doubled” every time you save the file. Working on the correct solution…

Here we go. The final version is: `(!?\[[^\]]+\]\()\<?([^>)]+)\>?\)` + `gm` + `$1<$2>)` .

Alternatively, if you want to have it more balanced: `(!?\[[^\]]+\])\(\<?([^>)]+)\>?\)` + `gm` + `$1(<$2>)` .

Or even: `!?\[([^\]]+)\]\(\<?([^>)]+)\>?\)` + `gm` + `![$1](<$2>)` .

As you can see, there is no one way to skin the cat. 😉 I have added a `?` after the `!` just to be on the safe side regarding non-image linking, i.e., normal MD links.

The `regex` does cover only one level. In the third example, only the inner MD link (the link text portion) is handled, and the outer one is left untouched. I leave it to you as an exercise.

```auto
[Pasted image 20230917184634.png](Pasted image 20230917184634.png "This is a title")

![Pasted image 20230917184634.png](Pasted image 20230917184634.png "This is a title")

[![Pasted image 20230917184634.png](Pasted image 20230917184634.png)](Pasted image 20230917184634.png "This is a title")

```

---

<div class="post-metadata">

**Author:** ![stef.rausch](https://forum.obsidian.md/user_avatar/forum.obsidian.md/stef.rausch/32/51207_2.png) [@stef.rausch](https://forum.obsidian.md/u/stef.rausch)\
**Post date:** [September 20, 2023, 11:25pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/6 "2023-09-20T23:25:19Z")

</div>

The rabbit hole is deep!

The approach is threefold and seems to be working fine – at least for now and still only for one level:

- `%20` + `gm` + `SPACE`: removes the URI encoding
- `\]\((.+?\.(png|jpg)).*?\.(png|jpg)([^)]*)\)` + `gm` + `]($1$4)`: removes the old “duplicate” partial file name – Obsidian bug when renaming the target
- `(!?\[[^\]]+\])\(\<?([^>")]+)\>?( +("[^"]*"))?\)` + `gm` + `$1(<$2>$3)`: adds the `<>` and correctly handles a link title

Enjoy!

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [December 19, 2023, 11:26pm UTC](https://forum.obsidian.md/t/how-can-i-make-obsidian-to-use-commonmark-links-specification-by-default-rather-than-wikilink/67565/7 "2023-12-19T23:26:18Z")

</div>

Closed on December 19, 2023, 11:26pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
