Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vincent-picaud opened this issue Oct 11, 2017 · 2 comments
Closed
Labels

Comments

@vincent-picaud
Copy link

vincent-picaud commented Oct 11, 2017

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

@sprig
Copy link
Owner

sprig commented Nov 30, 2017

:-) Thanks for pointing this out!

I'm not sure there is a better solution than what you posted to be found - I believe the extension itself should send the data to emacs unmodified since various users could have different templates (i.e. the templates in the readme should be viewed as a starting point for further modification). I guess the original org link format was not designed to have links with square brackets in their descriptions.

I'll add your solution to the readme - in the future, feel free to create the PR :-)

@sprig sprig closed this as completed Nov 30, 2017
@sprig sprig added the fixed label Nov 30, 2017
@vincent-picaud
Copy link
Author

I understand and do agree. Next time I will think of PR :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants