emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `:export' attribute?: Re: Experimental public branch for inline spec


From: Max Nikulin
Subject: Re: `:export' attribute?: Re: Experimental public branch for inline special blocks
Date: Fri, 15 Mar 2024 17:52:48 +0700
User-agent: Mozilla Thunderbird

On 15/03/2024 09:19, Juan Manuel Macías wrote:
The attribute supports one or more elements separated by a space. Each
element can be any of the following signs: "*" (export only the
content), "-" (do not export), "=" (export the rest normally), "=*"
(export the rest, but only the content), "=-" (do not export the rest).
Additionally, backend names can be given explicitly, alone or
accompanied by the "*" or "-" signs, that is (where "backend" equals the
name of the backend):

1. "-" is a valid backend name and valid last character of backend name
2. From the description it is not clear to me what is effect of "rest" specified for more than one backend.

I have had into the code. I would expect something like the following (characters may be changed, the code is not heavily tested). Two characters from the following groups may be appended to backend name:

+ full (default)
* content
/ skip
(these ones may be used without backed name to specify fallback action)

= this and derived backends (default)
. this, but not derived backends
Perhaps it is necessary to add possibility that
these rules may coexist (use loop instead of assoc)

(ignore
 (pp
  (let ((rules
         (org-export--inline-special-block-make-backend-alist
          (org-split-string "latex/ html./ ascii+ *"))))
    (mapcar (lambda (backend)
              (list backend
(org-export--inline-special-block-export-decision rules backend)))
            '(odt latex beamer html md ascii)))))

Gives

((odt content)
 (latex nil)
 (beamer nil)
 (html nil)
 (md content)
 (ascii full))

Function definitions:

(defun org-export--inline-special-block-make-backend-alist
    (rules)
  (nconc
   (let (result)
     (dolist (spec rules)
       (if (string-match

"\\`\\([-_a-zA-Z0-9]*\\)\\(?:\\([/+*]\\)\\|\\([=.]\\)\\([/+*]\\)?\\)?\\'"
            spec)
           (let ((name (match-string 1 spec))
                 (inherit (match-string 3 spec))
                 (what (or (match-string 2 spec)
                           (match-string 4 spec))))
             (push (cons
                    (if (string-equal "" name) '@ (intern name))
                    (cons (or (not inherit) (string-equal inherit "="))
                          (if what (string-to-char what) ?+)))
                   result))
         (message "invalid :export specification %S" spec)))
     result)))

(defun org-export--inline-special-block-export-decision
    (rules-alist backend)
  (when (symbolp backend)
    (setq backend (org-export-get-backend backend)))
  (let* ((rule (assoc (org-export-backend-name backend) rules-alist))
         (decision (and rule (cddr rule))))
    (while (and (not decision)
                (setq backend (org-export-backend-parent backend)))
      (setq backend (org-export-get-backend backend))
(when (and (setq rule (assq (org-export-backend-name backend) rules-alist))
                 rule
                 (cadr rule))
        (setq decision (cddr rule))))
    (unless decision
      (setq rule  (assq '@ rules-alist))
      (setq decision (and rule (cddr rule))))
    (pcase decision
      (?+ 'full)
      (?* 'content)
      (?/ nil)
      (_ 'full))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]