Skip to content

Brackets '[' ']' in link description cause broken org-mode link #37

@vincent-picaud

Description

@vincent-picaud

Thank you for this great extension, it worked out of the box with my config (Debian distro).

I just had some problems with ArXiv.org links (https://arxiv.org/abs/1606.04838 for instance), because page tile:

[1606.04838] Optimization Methods for Large-Scale Machine Learning

contains [, ] brackets.

Using the org-capture-template:

(setq org-capture-templates `(
	
	("L" "Protocol Link" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
        "* %? [[%:link][%:description]]\n")
))

returns broken org-mode link.

I used a function to convert [, ] char into (, ) to fix this:

(defun transform-square-brackets-to-round-ones(string-to-transform)
  "Transforms [ into ( and ] into ), other chars left unchanged."
  (concat 
  (mapcar #'(lambda (c) (if (equal c ?[) ?\( (if (equal c ?]) ?\) c))) string-to-transform))
  )

(setq org-capture-templates `(
	
	("L" "Protocol Link" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
        "* %? [[%:link][%(transform-square-brackets-to-round-ones \"%:description\")]]\n")
))

but I think that there is certainly better/more elegant fix.

Maybe it would be interesting to mention this potential problem in the doc (ArXiv is a widely used site)

Best,
Vincent

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions