Skip to content

Commit

Permalink
Fix: Org 9.3's org-bracket-link-regexp
Browse files Browse the repository at this point in the history
Thanks to Aaron Zeng (@bcc32) and Akira Komamura (@akirak).
  • Loading branch information
alphapapa committed Dec 12, 2020
2 parents ebc7888 + fed3b89 commit b94a07a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Install [[https://github.com/magnars/dash.el][dash.el]], [[https://github.com/ta

** 1.2-pre

*Compatibility*
+ Updated for Org 9.3's changes to ~org-bracket-link-regexp~. (Thanks to [[https://github.com/bcc32][Aaron Zeng]] and [[https://github.com/akirak][Akira Komamura]].)

*Fixed*
+ =org-web-tools--org-link-for-url= now returns the URL if the HTML page has no title tag. This avoids an error, e.g. when used in an Org capture template.

Expand Down
8 changes: 6 additions & 2 deletions org-web-tools.el
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ tag)."
(org-web-tools--get-first-url)
(read-string "URL: ")))

(defconst org-web-tools--link-desc-submatch
(if (version<= "9.3" org-version) 2 3)
"Match group index of link description in `org-bracket-link-regexp'.")

(defun org-web-tools--read-org-bracket-link (&optional link)
"Return (TARGET . DESCRIPTION) for Org bracket LINK or next link on current line."
;; Searching to the end of the line seems the simplest way
Expand All @@ -515,11 +519,11 @@ tag)."
;; Link passed as arg
(when (string-match org-bracket-link-regexp link)
(setq target (match-string-no-properties 1 link)
desc (match-string-no-properties 3 link)))
desc (match-string-no-properties org-web-tools--link-desc-submatch link)))
;; No arg; get link from buffer
(when (re-search-forward org-bracket-link-regexp (point-at-eol) t)
(setq target (match-string-no-properties 1)
desc (match-string-no-properties 3))))
desc (match-string-no-properties org-web-tools--link-desc-submatch))))
(when (and target desc)
;; Link found; return parts
(cons target desc)))))
Expand Down

0 comments on commit b94a07a

Please sign in to comment.