[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: org-element: headline's :title is sometimes string, sometimes list
From: |
Ihor Radchenko |
Subject: |
Re: org-element: headline's :title is sometimes string, sometimes list |
Date: |
Wed, 23 Aug 2023 09:49:22 +0000 |
Hraban Luyat <hraban@0brg.net> writes:
> I expect: "string" everywhere.
>
> I get:
>
> Headline title from map is of type: cons
> Headline title from context is of type: string
> Headline title from at-point is of type: string
>
> Question 1: Do you know what that `cons' structure is? Where is it
> documented, how would I go about figuring this out myself? The
> org-element API documentation is daunting.
This is "anonymous element". `org-element-parse-buffer', by default,
parses down to object level:
* Heading *bold* text
contains bold markup, which is reflected in the parsed AST. The title
itself is called secondary value, which may contain Org markup.
You are not getting it using `org-element-at-point' API because it does
not parse objects and simply returns a heading parsed down to element
level - :title is not parsed in details.
> Question 2: how do I reliably get the title as a string? Properties are
> fine, I don't mind, but that weird list structure is awkward to handle.
Use `org-element-interpret-data' to convert Org AST back to plain text.
--
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>