[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ox.el: Refactor variable org-html--id-attr-prefix, ox-html.e
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] ox.el: Refactor variable org-html--id-attr-prefix, ox-html.el: Add support for the ID property to org-html--reference |
Date: |
Tue, 25 Oct 2022 07:18:18 +0000 |
Feraidoon Mehri <feraidoonmehri@gmail.com> writes:
> I have already signed the copyright assignment. (Though I used my
> other email rudiwillalwaysloveyou@gmail.com when signing it.)
Bastien, could you kindly check the FSF records?
> I have manually tested the changes with a custom value for
> `org-html--id-attr-prefix', and everything works.
>
> I did not change the behavior of `org-html-prefer-user-labels'; the ID
> property will not be used if `org-html-prefer-user-labels' is nil. IMO
> this behavior should be changed, and it should be always used, just
> like CUSTOM_ID.
Thanks for the patch!
See my comments below.
> * org/ox.el (org-html--id-attr-prefix): Refactor hardcoded "ID-" as a
> new private variable.
org-html-* variable do not belong to the general ox.el library. It
should only be added to ox-html.el.
> - (user-label
> - (org-element-property
> - (pcase type
> - ((or `headline `inlinetask) :CUSTOM_ID)
> - ((or `radio-target `target) :value)
> - (_ :name))
> - datum)))
> + (custom-id-p nil)
> + (user-label
> + (or
> + (org-element-property
> + (pcase type
> + ((or `headline `inlinetask)
> + (progn
> + (setq custom-id-p t)
> + :CUSTOM_ID))
> + ((or `radio-target `target) :value)
> + (_ :name))
> + datum)
> + (if-let
> + ((id-property (org-element-property
> + :ID
> + datum)))
> + (progn
> + (setq custom-id-p nil)
> + (concat org-html--id-attr-prefix id-property))))))
This is a bit awkward to read.
Can you instead let-bind custom-id as a separate variable and leave :ID
to user-label? Then, you will not need to juggle setq custom-id-p and
the code will become more readable.
> diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
> index 7f2e8ba47f..d2c14237ac 100644
> --- a/lisp/org/ox-odt.el
> +++ b/lisp/org/ox-odt.el
> @@ -1802,7 +1802,7 @@ holding contextual information."
> ;; Extra targets.
> (extra-targets
> (let ((id (org-element-property :ID headline)))
> - (if id (org-odt--target "" (concat "ID-" id)) "")))
> + (if id (org-odt--target "" (concat org-html--id-attr-prefix id))
> "")))
It is surprising that org-html-* variable has anything to do with ODT
export. Please define a separate constant in ox-odt.
--
Ihor Radchenko // yantar92,
Org mode contributor,
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>