Skip to content

Commit f99902e

Browse files
committed
ox-publish: Allow linking to encrypted Org files
* lisp/ox-html.el (org-html-link): Convert .org.gpg file links to .html, in addition to previously performed .org -> .html convertion. (org-html-link-org-files-as-html): Update the docstring. * doc/org-manual.org (Publishing links): * etc/ORG-NEWS (Publishing now supports links to encrypted Org files): Document the new feature.
1 parent 3b0c4ad commit f99902e

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

doc/org-manual.org

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16472,13 +16472,16 @@ Settings]]), however, override everything.
1647216472
#+cindex: links, publishing
1647316473

1647416474
To create a link from one Org file to another, you would use something
16475-
like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]). When
16476-
published, this link becomes a link to =foo.html=. You can thus
16477-
interlink the pages of your "Org web" project and the links will work
16478-
as expected when you publish them to HTML. If you also publish the
16479-
Org source file and want to link to it, use an =http= link instead of
16480-
a =file:= link, because =file= links are converted to link to the
16481-
corresponding =.html= file.
16475+
like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see
16476+
[[*External Links]]). When published, this link becomes a link to
16477+
=foo.html=. You can thus interlink the pages of your "Org web"
16478+
project and the links will work as expected when you publish them to
16479+
HTML. If you also publish the Org source file and want to link to it,
16480+
use an =http= link instead of a =file:= link, because =file= links are
16481+
converted to link to the corresponding =.html= file.
16482+
16483+
Links to encrypted Org files, like =[[file:foo.org.gpg]]= are also
16484+
supported.
1648216485

1648316486
You may also link to related files, such as images. Provided you are
1648416487
careful with relative file names, and provided you have also

etc/ORG-NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ discouraged when working with Org files.
143143
*** Clock table can now produce quarterly reports
144144

145145
=:step= clock table parameter can now be set to =quarter=.
146+
*** Publishing now supports links to encrypted Org files
147+
148+
Links to other published Org files are automatically converted to the
149+
corresponding html links. Now, this feature is also available when
150+
links point to encrypted Org files, like
151+
=[[file:foo.org.gpg::Heading]]=.
146152

147153
*** Interactive commands now support escaping text inside comment blocks
148154

lisp/ox-html.el

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ are directly put into a \"href\" tag in HTML. However, links to other Org files
839839
(recognized by the extension \".org\") should become links to the corresponding
840840
HTML file, assuming that the linked Org file will also be converted to HTML.
841841
842+
Links to \"file.org.gpg\" are also converted.
843+
842844
When nil, the links still point to the plain \".org\" file."
843845
:group 'org-export-html
844846
:type 'boolean)
@@ -3066,12 +3068,13 @@ INFO is a plist holding contextual information. See
30663068
(lambda (raw-path info)
30673069
;; Treat links to `file.org' as links to `file.html', if
30683070
;; needed. See `org-html-link-org-files-as-html'.
3069-
(cond
3070-
((and (plist-get info :html-link-org-files-as-html)
3071-
(string= ".org"
3072-
(downcase (file-name-extension raw-path "."))))
3073-
(concat (file-name-sans-extension raw-path) dot html-ext))
3074-
(t raw-path))))
3071+
(save-match-data
3072+
(cond
3073+
((and (plist-get info :html-link-org-files-as-html)
3074+
(let ((case-fold-search t))
3075+
(string-match "\\(.+\\)\\.org\\(?:\\.gpg\\)?$" raw-path)))
3076+
(concat (match-string 1 raw-path) dot html-ext))
3077+
(t raw-path)))))
30753078
(type (org-element-property :type link))
30763079
(raw-path (org-element-property :path link))
30773080
;; Ensure DESC really exists, or set it to nil.

0 commit comments

Comments
 (0)