I want to change the Obsdian link format

Things I have tried

I am writing a paper in Obsidian. I use Zotero to manage my references and use a unique key output by Better BibTeX. I have installed the Citations plugin. When I want to include a citation in the manuscript, I use Ctrl+Shift+E to find it.

Then a key like [[@Fuji2007]] is inserted. This is an internal link in Obsdian, and this title note contains the automatically generated bibliographic information and what I felt when I read it.

I convert this in an external Pndoc (terminal), link it to the Refernece, and generate a Word file. Because I need to submit this file to an English proofreader.

The problem here is Obsidian’s double bracketing. That is, if I convert [[@Fuji2007]] in Pandoc, it will look like [(Fuji et al., 2007)]. All I really want is (Fuji et al., 2007). I don’t need the outer square brackets.

What I’m trying to do

I tried to use the Lua filter to remove the square brackets when I run Pandoc in the terminal, but it didn’t work. All the brackets disappear. I tried another code, but it did not work.

function Str (str)
return (str.text
:gsub(“%[”, “”)
:gsub(“%]”, “”)
)
end

So I would like to know if there is a way to export a link in Obsidian with the formatting changed from double to single.

1 Like

I don’t know Lua, but I’m guessing you might change

:gsub(“%[”, “”)
:gsub(“%]”, “”)

to

:gsub(“%[[”, “[”)
:gsub(“%]]”, “]”)

It looks to me like the code you posted replaces every bracket with nothing. I don’t know if my altered version works (again: I don’t know Lua), but the intent is to replace pairs of brackets with single brackets.

I would try :

function Str (str)
    return (str.text
    :gsub('%[%[', '[')
    :gsub('%]%]', ']'))
 end

Hi guys,

Thank you for replying.

These seem to be very attractive solutions, but for some reason they didn’t work - maybe there is a problem with Lua’s escaping process.

I am converting double brackets to singles with Obisidian’s Replace. However, this way I have to replace twice each time I export to Pandoc, and when I am done exporting, I have to put it back again. This is not a very smart way.

Does anyone know of a “smart” way to switch between Obsidian citation brackets [[]] and Pandoc citation brackets [] in one click?

Is your pandoc the latest version ?
My proposal won’t work if it’s not Pandoc v2.19 I think

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