Earl Chase <[email protected]> writes: > etc/ORG-NEWS | 21 +++ > lisp/ox-html.el | 55 +++++--- > testing/lisp/test-ox-html.el | 241 +++++++++++++++++++++++++++++++++++
I think we should also document the new option in the manual. > +(defcustom org-html-base-directory nil > + "Directory of the project that you intend to export. > +This variable is the equivalent of the `:base-directory' > +key of `org-publish-project-alist'. If `:base-directory' > +is also set, the value of this variable will be ignored." > + :group 'org-export-html > + :type 'string) Please add :package-version and :safe keywords. > +(defun org-html--create-file-link-path (raw-path info) > + "Convert RAW-PATH into a HTML file link path. > +During publishing, turn absolute file names belonging to > +base directory into relative file names. Otherwise, > +append `file' protocol to absolute file name. INFO > +should be the export options, as a plist." > + (let* ((html-base-directory (plist-get info :html-base-directory)) > + (updated-info (if (and html-base-directory > + (not (plist-get info > + :base-directory))) > + (plist-put info > + :base-directory > + html-base-directory) > + info)) Mutating INFO can cause unintended side effects. Rather than trying to change INFO + calling org-publish-file-relative-name, we should factor out org-publish-file-relative-name into a more global function (in ox.el) and use it from ox-html and ox-publish. I imagine that function to look like (org-export-file-relative-name-maybe filename base-directory) > + (file-relative-name (org-publish-file-relative-name > + raw-path updated-info)) > + (home (and (plist-get info :html-link-home) > + (org-trim (plist-get info :html-link-home))))) > + ;; Possibly append `:html-link-home' to relative file > + ;; name. *prepend :) > + (if (and home > + (plist-get info :html-link-use-abs-url) > + (not (file-name-absolute-p file-relative-name))) This reads awkward. Maybe we need to name FILE-RELATIVE-NAME variable better. > +(defun test-ox-html-create-test-link-element (test-link-path > + &optional test-desc) > + "Helper function for `ox-html-link' tests. > +Uses TEST-LINK-PATH and TEST-DESC to create a file link. > +That file link will then be converted into an org-element." > + (let ((test-desc (if test-desc > + (format "[[file:%s][%s]]" > + test-link-path > + test-desc) > + (format "[[file:%s]]" > + test-link-path)))) You can just use org-link-make-string. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
