[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote b0eee438c1 4/7: Make Org export correctly add th
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote b0eee438c1 4/7: Make Org export correctly add the search to the anchor |
Date: |
Wed, 14 Feb 2024 03:57:57 -0500 (EST) |
branch: externals/denote
commit b0eee438c19f89e5dc76bb7afdd2fd22b4ef7b22
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make Org export correctly add the search to the anchor
This is relevant when the 'denote:' link has an optional search
extension to jump to a location (same as with the standard Org 'file:'
link type). Denote uses this facility with the command
'denote-org-extras-link-to-heading', which is part of the new optional
extension 'denote-org-extras.el'.
Thanks to @fingerknight for noting that the search extension for not
part of the exported link anchor. This was done in issue 250:
<https://github.com/protesilaos/denote/issues/250>.
---
README.org | 4 ++--
denote.el | 32 +++++++++++++++++++-------------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/README.org b/README.org
index cafc0a4fb9..8ae3353d7a 100644
--- a/README.org
+++ b/README.org
@@ -5054,8 +5054,8 @@ Denote is meant to be a collective effort. Every bit of
help matters.
Niall Dooley, Paul van Gelder, Peter Prevos, Peter Smith, Suhail
Singh, Shreyas Ragavan, Stefan Thesing, Summer Emacs, Sven Seebeck,
Taoufik, TJ Stankus, Viktor Haag, Wade Mealing, Yi Liu, Ypot,
- atanasj, babusri, doolio, drcxd, hpgisler, pRot0ta1p, rbenit68,
- relict007, sienic, sundar bp.
+ atanasj, babusri, doolio, drcxd, fingerknight, hpgisler, pRot0ta1p,
+ rbenit68, relict007, sienic, sundar bp.
Special thanks to Peter Povinec who helped refine the file-naming
scheme, which is the cornerstone of this project.
diff --git a/denote.el b/denote.el
index 4e57a25bd2..e148bc554b 100644
--- a/denote.el
+++ b/denote.el
@@ -4047,10 +4047,9 @@ This command is meant to be used from a Dired buffer."
(declare-function org-link-open-as-file "ol" (path arg))
-(defun denote-link--ol-resolve-link-to-target (link &optional path-id)
- "Resolve LINK into the appropriate target.
-With optional PATH-ID return a cons cell consisting of the path
-and the identifier."
+(defun denote-link--ol-resolve-link-to-target (link &optional full-data)
+ "Resolve LINK to target file, with or without additioanl search terms.
+With optional FULL-DATA return a list in the form of (path id search)."
(let* ((search (and (string-match "::\\(.*\\)\\'" link)
(match-string 1 link)))
(id (if (and search (not (string-empty-p search)))
@@ -4058,8 +4057,8 @@ and the identifier."
link))
(path (denote-get-path-by-id id)))
(cond
- (path-id
- (cons (format "%s" path) (format "%s" id)))
+ (full-data
+ (list path id search))
((and search (not (string-empty-p search)))
(concat path "::" search))
(path))))
@@ -4141,17 +4140,24 @@ Also see the user option
`denote-org-store-link-to-heading'."
"Export a `denote:' link from Org files.
The LINK, DESCRIPTION, and FORMAT are handled by the export
backend."
- (let* ((path-id (denote-link--ol-resolve-link-to-target link :path-id))
- (path (file-relative-name (car path-id)))
- (p (file-name-sans-extension path))
- (id (cdr path-id))
- (desc (or description (concat "denote:" id))))
+ (let* ((path-id (denote-link--ol-resolve-link-to-target link :full-data))
+ (path (file-relative-name (nth 0 path-id)))
+ (id (nth 1 path-id))
+ (search (nth 2 path-id))
+ (anchor (file-name-sans-extension path))
+ (desc (cond
+ (description)
+ (search (format "denote:%s::%s" id search))
+ (t (concat "denote:" id)))))
(cond
- ((eq format 'html) (format "<a href=\"%s.html\">%s</a>" p desc))
+ ((eq format 'html)
+ (if search
+ (format "<a href=\"%s.html%s\">%s</a>" anchor search desc)
+ (format "<a href=\"%s.html\">%s</a>" anchor desc)))
((eq format 'latex) (format "\\href{%s}{%s}" (replace-regexp-in-string
"[\\{}$%&_#~^]" "\\\\\\&" path) desc))
((eq format 'texinfo) (format "@uref{%s,%s}" path desc))
((eq format 'ascii) (format "[%s] <denote:%s>" desc path)) ; NOTE
2022-06-16: May be tweaked further
- ((eq format 'md) (format "[%s](%s.md)" desc p))
+ ((eq format 'md) (format "[%s](%s.md)" desc anchor))
(t path))))
;; The `eval-after-load' part with the quoted lambda is adapted from
- [elpa] externals/denote updated (38ada4ecba -> 561911e747), ELPA Syncer, 2024/02/14
- [elpa] externals/denote b0eee438c1 4/7: Make Org export correctly add the search to the anchor,
ELPA Syncer <=
- [elpa] externals/denote afe1f37d4f 1/7: Remove denote-user-enforced-denote-directory, ELPA Syncer, 2024/02/14
- [elpa] externals/denote a48a1da067 2/7: Make denote-user-enforced-denote-directory an alias of denote-directory, ELPA Syncer, 2024/02/14
- [elpa] externals/denote 37d24168ba 3/7: Update the manual's acknowledgements., ELPA Syncer, 2024/02/14
- [elpa] externals/denote 0c5a044019 5/7: Fix file extension of Org markdown export, ELPA Syncer, 2024/02/14
- [elpa] externals/denote f1036f9af3 6/7: Remove needless comment about possible tweak to Org ascii export, ELPA Syncer, 2024/02/14
- [elpa] externals/denote 561911e747 7/7: Use the new 'denote-parse-date' throughout denote-journal-extras, ELPA Syncer, 2024/02/14