Comments (3)
Thank you @fingerknight!
Can you try a diff?
denote.el | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/denote.el b/denote.el
index c3e5cb5..c0f8a4c 100644
--- a/denote.el
+++ b/denote.el
@@ -4080,10 +4080,9 @@ ;;;;; Register `denote:' custom Org hyperlink
(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)))
@@ -4091,8 +4090,8 @@ (defun denote-link--ol-resolve-link-to-target (link &optional path-id)
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))))
@@ -4174,17 +4173,24 @@ (defun denote-link-ol-export (link description format)
"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))
+ (anchor-html (if search
+ (concat (file-name-sans-extension path) search)
+ anchor))
+ (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) (format "<a href=\"%s.html\">%s</a>" anchor-html 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
from denote.
Perhaps I have not clarified the case.
Assume there are two files a.org
:
* Headline
content
and b.org
:
[[denote:a::Headline][NAME]]
Exported b.org
, we should obatin <a href="a.html#Headline">NAME</a>
, Headline
being a HTML anchor.
The diff is just to adjust the exported file name.
For html
, it should be like
(format "<a href=\"%s.html%s\">%s</a>"
(file-name-sans-extension path)
(if search
(concat "#" search)
"")
desc)
As for md, I have no idea if it has the syntax to link to the Headline at the other file.
from denote.
Thank you for clarifying! I pushed the changes.
from denote.
Related Issues (20)
- Denote mutates passed-in lists when sorting HOT 4
- `--` in titles HOT 41
- `denote-extract-filename-title` (simpler/minimal version of `denote-retrieve-filename-title`) HOT 4
- Enhancing `denote-rewrite-front-matter` to save and kill buffer when it's safe to do so HOT 4
- Option to ask `y` or `n` just once from `denote-rename-file` HOT 2
- `denote-retrieve-filename-title` body vs docstring HOT 1
- Separate faces for year, month, day, hour, minute, and second in dired fontification please HOT 3
- `denote-file-is-note-p`, but `t` if file exists *or* buffer visiting file exists HOT 1
- Hacking `denote-rename-file` to allow changing the ID HOT 15
- Enhancing `denote-rename-file` to handle not-yet-saved visiting buffer HOT 3
- Denote file names... without ID (cue ominous music) HOT 16
- Path in `denote-backlinks` buffer is wrong (extra directory in the link) HOT 5
- A `denote-filetype-heuristics` variant to help other code HOT 5
- sort by title outside of denote-directory HOT 5
- I use `denote-rename-file` as my main file renaming UI HOT 6
- `denote--edit-front-matter-p` docstring vs behavior HOT 1
- Possible to create a denote file outside denote-directory? HOT 5
- markdown links HOT 3
- Commit 232bd90 does not only apply to signatures HOT 13
- is it possible to create single tag with multiple words seperated by delimter? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from denote.