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: Juan Manuel Macías
Subject: Re: `:export' attribute?: Re: Experimental public branch for inline special blocks
Date: Fri, 15 Mar 2024 16:26:15 +0000

Max Nikulin writes:

> (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))))

I've been testing your code and it works very well. It is certainly
finer than the current approach. I think it could be implemented, and we
are testing that.

Tomorrow I will make a new commit with your code.

-- 
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño 
editorial y ortotipografía




reply via email to

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