From dc2d3f0e204c5cdeaea8bcd9ecd6eef1da95e998 Mon Sep 17 00:00:00 2001 From: Daniel Nicolai Date: Fri, 10 Jan 2020 23:13:54 +0100 Subject: [PATCH 1/5] Add support for internal links The internal link in ox-html is a little fuzzy. For example, [[./test.org][test]] will be generated as "test" because the path is considered as an absolute file path. In order to correctly generate internal link urls, you may write [[int-url:./test][test], JUST THE FILENAME WITHOUT THE .org EXTENSION PART and then it should be generated as "test". This is just a slightly adapted copy if the img-url solution for image url's --- v8/orgmode/init.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v8/orgmode/init.el b/v8/orgmode/init.el index 93b29672..9881c691 100644 --- a/v8/orgmode/init.el +++ b/v8/orgmode/init.el @@ -111,6 +111,13 @@ contextual information." (pygmentize (downcase lang) (org-html-decode-plain-text code))) code-html)))) +;; Export internal links with custom link type +(defun org-custom-internal-link-url-export (path desc format) + (cond + ((eq format 'html) + (format "\"%s\"" path desc)))) +(org-add-link-type "int-url" nil 'org-custom-internal-link-url-export) + ;; Export images with custom link type (defun org-custom-link-img-url-export (path desc format) (cond From 714e2bc6d148dba3e4a82bc8d5929767671183cb Mon Sep 17 00:00:00 2001 From: Daniel Nicolai Date: Fri, 10 Jan 2020 23:17:23 +0100 Subject: [PATCH 2/5] Add documentation for how to handle internal links --- v8/orgmode/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v8/orgmode/README.md b/v8/orgmode/README.md index eedcc311..3260b52d 100644 --- a/v8/orgmode/README.md +++ b/v8/orgmode/README.md @@ -44,3 +44,7 @@ because the path is considered as an absolute file path. In order to correctly generate image urls, you may write `[[img-url:/images/test.jpg]]`, and then it should be generated as `test.jpg`. + +The internal link in ox-html is a little fuzzy. For example, `[[./test.org][test]]` will be generated as `"test"` because the path is considered as an absolute file path. + +In order to correctly generate internal link urls, you may write `[[int-url:./test][test]` (i.e. JUST THE FILENAME WITHOUT THE .org EXTENSION PART), and then it should be generated as "test". From 8c7a27e83b6e7142e003587ac9125aa1a4adf678 Mon Sep 17 00:00:00 2001 From: Daniel Nicolai Date: Sun, 12 Jan 2020 14:20:46 +0100 Subject: [PATCH 3/5] improve internal link export function 1. Change link prefix from 'int-url' to 'internal'. 2. Replace 'path' with a substring method that removes the .org extension in from the original org source file syntax to make the 'internal link' export function work similar as the 'img-url' export function, and also to keep the differences between a nikola org source file minimal with the original org source file. --- v8/orgmode/init.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v8/orgmode/init.el b/v8/orgmode/init.el index 9881c691..017c5c03 100644 --- a/v8/orgmode/init.el +++ b/v8/orgmode/init.el @@ -115,8 +115,8 @@ contextual information." (defun org-custom-internal-link-url-export (path desc format) (cond ((eq format 'html) - (format "\"%s\"" path desc)))) -(org-add-link-type "int-url" nil 'org-custom-internal-link-url-export) + (format "\"%s\"" (substring path 0 -4) desc)))) +(org-add-link-type "internal" nil 'org-custom-internal-link-url-export) ;; Export images with custom link type (defun org-custom-link-img-url-export (path desc format) From 140b922e6f14e3366694c544ebdee4d961c2dfa6 Mon Sep 17 00:00:00 2001 From: Daniel Nicolai Date: Sun, 12 Jan 2020 14:29:52 +0100 Subject: [PATCH 4/5] updates for internal link pull request update link prefix from 'int-url' to 'internal'. Remove reuirement to leave out .org extension in link (this is removed by a substring method in the init.el file) --- v8/orgmode/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v8/orgmode/README.md b/v8/orgmode/README.md index 3260b52d..740cb696 100644 --- a/v8/orgmode/README.md +++ b/v8/orgmode/README.md @@ -45,6 +45,6 @@ because the path is considered as an absolute file path. In order to correctly generate image urls, you may write `[[img-url:/images/test.jpg]]`, and then it should be generated as `test.jpg`. -The internal link in ox-html is a little fuzzy. For example, `[[./test.org][test]]` will be generated as `"test"` because the path is considered as an absolute file path. +The internal link in ox-html is a little fuzzy. For example, `[[./test.org][test]]` will be generated as `"test"` because the path is considered as an absolute file path. -In order to correctly generate internal link urls, you may write `[[int-url:./test][test]` (i.e. JUST THE FILENAME WITHOUT THE .org EXTENSION PART), and then it should be generated as "test". +In order to correctly generate internal link urls, you may write `[[internal:./test.org][test]`, and then it should be generated as "test". From eacaf301511b17b035e6adb6f5480a2b95fbe12d Mon Sep 17 00:00:00 2001 From: Daniel Nicolai Date: Sun, 12 Jan 2020 14:47:22 +0100 Subject: [PATCH 5/5] remove index.html from internal link --- v8/orgmode/init.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v8/orgmode/init.el b/v8/orgmode/init.el index 017c5c03..461f33d6 100644 --- a/v8/orgmode/init.el +++ b/v8/orgmode/init.el @@ -115,7 +115,7 @@ contextual information." (defun org-custom-internal-link-url-export (path desc format) (cond ((eq format 'html) - (format "\"%s\"" (substring path 0 -4) desc)))) + (format "\"%s\"" (substring path 0 -4) desc)))) (org-add-link-type "internal" nil 'org-custom-internal-link-url-export) ;; Export images with custom link type