Nikolaos Chatzikonstantinou <nchatz...@gmail.com> writes:

> #+begin_src elisp
> (defun blorg-html-italic (_italic contents info)
>   "Transcode ITALIC from Org to HTML for a blog.
> Italicize if in title, otherwise emphasize."
>   (format
>    (or (cdr (assq 'italic (plist-get info :html-text-markup-alist))) "%s")
>    contents))
> #+end_src
>
> I cannot tell what the three arguments _italic, contents, info are
> for, even after reading the docs, and after inspecting them with
> edebug. Do I need to understand Org ASTs? Do I need to understand
> Org-publish better? I'm just at loss here.

ITALIC contains AST node holding the markup to be exported. You can
access the whole exported parse tree starting from it (via
org-element-parent/org-element-contents/etc)

CONTENTS is the already exported (recursively) contents inside italic
markup. For example, when you have /text, *inner bold*, [[file:link]]/,
CONTENTS will contain everything inside properly exported into the
target format.

INFO is a plist containing exporter settings. It is used to pass around
user customization like :with-title/:with-author and also the data that
needs to be cached across individual transcoders (INFO can be modified
in place)

> Specifically, how do I obtain the contextual information that tells me
> whether I'm a headline or in body?

For example,

(let ((first-child italic))
 (while (not (org-element-type-p first-child '(headline inlinetask)))
   (setq first-child (org-element-parent first-child)))
 (org-element-secondary-p first-child))

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

Reply via email to