emacs-orgmode
[Top][All Lists]
Advanced

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

Re: multipage html output


From: Ihor Radchenko
Subject: Re: multipage html output
Date: Tue, 23 Jul 2024 14:13:53 +0000

Orm Finnendahl <orm.finnendahl@selma.hfmdk-frankfurt.de> writes:

>> > - added :multipage case to `org-export-as', calling :process-multipage
>> >   callback submitted in info. In the multipage case, org-export-as
>> >   returns nil relying on :process-multipage to do the exporting, while
>> >   in the single page case it returns the transcoded string to the
>> >   caller from the backend.
>> 
>> Does it mean that you do not want page splitting to be controlled
>> globally, in ox.el, as we discussed?
>
> Not for now (I mention that later in the mail when I talk about
> section-filenames and future generalizations, where this definitely
> has to be done). In the html multipage export are many peculiarities
> which don't apply to other backends, so ox.el wouldn't be the place
> for it, so we will need some callback mechanism anyway.
>
> Right now this gets accomplished with a small branch in org-export-as
> in order to change as little as possible. It'll be easy to change if
> we find a good way to get this done using a more general approach. But
> I'm open for suggestions, if you have an idea how to already do it
> now.

Then, a more natural way to achieve custom document-wide transcoder will
be introducing "org-data" transcoder into `org-export-transcoder':

(defun org-export-transcoder (blob info)
  "Return appropriate transcoder for BLOB.
INFO is a plist containing export directives."
  (let ((type (org-element-type blob)))
    ;; Return contents only for complete parse trees.
    (if (eq type 'org-data) (lambda (_datum contents _info) contents) ; 
<=------------------
      (let ((transcoder (cdr (assq type (plist-get info :translate-alist)))))
        (and (functionp transcoder) transcoder)))))

For now, we have a hard-coded identity CONTENTS -> CONTENTS transcoder
when exporting the whole document, followed by applying inner/outer
templates. We may instead allow the export backends to introduce
"org-data" transcoder as a part of exporter definition. When non-nil, it
will be used instead of what you extracted into
`org-export-transcode-page'. And `org-export-transcode-page' will be
used as the fallback.

WDYT?

>> > - changed that `org-export-numbered-headline-p' always returns t for
>> >   headlines in the multipage case to ensure headline numbering is
>> >   collected.
>> 
>> >   NOTE: The single-page case will be handled like before, but it might
>> >   be a better idea to change the behaviour and do it the same way as
>> >   in the multipage case: Always collect the headline-numbering and
>> >   only decide at the transcoding stage whether the headline should be
>> >   numbered in the output.
>> 
>> Why? What if one wants headlines to be not numbered?
>
> Just set num:nil in the options.

But your code ignores num:nil, does it not?

(defun org-export-numbered-headline-p (headline info)
  "Return a non-nil value if HEADLINE element should be numbered.
INFO is a plist used as a communication channel."
  (unless (org-not-nil (org-export-get-node-property :UNNUMBERED headline t))
    (let ((sec-num (or (plist-get info :section-numbers)
                       (plist-get info :multipage))) ; <-- overrides num:nil
          (level (org-export-get-relative-level headline info)))
      (if (wholenump sec-num) (<= level sec-num) sec-num))))


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



reply via email to

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