So I was writing a function that would convert one type of a link (e.g. Org-mode link) to another type (e.g. Markdown), and then I realized that Org-mode doesn't require you to escape square brackets, i.e.,
if you have a link like this:
[[https://github.com/foo/bar/issues/42][Major issue in [Bar] project]]
Org mode would have no issues with displaying it (whereas Markdown would). And if you try to convert it to Markdown, you have to escape those square brackets.
Of course, I could do something like the following:
(let ((str "Major issue in [Bar] project"))
(replace-regexp-in-string "\\]" "\\\\]"
(replace-regexp-in-string "\\[" "\\\\[" str)))
;; => "Major issue in \\[Bar\\] project"
But I think it's possible to achieve the same result by calling the function only once and using optional arguments. Can someone show me how does it work?