From: Ihor Radchenko <yantar92@posteo.net>
To: Hraban Luyat <hraban@0brg.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-element: headline's :title is sometimes string, sometimes list
Date: Wed, 23 Aug 2023 09:49:22 +0000 [thread overview]
Message-ID: <87jztm6qcd.fsf@localhost> (raw)
In-Reply-To: <cf10ff8e-b22b-4a9e-bd63-4b7a5bcc6df4@0brg.net>
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>
next prev parent reply other threads:[~2023-08-23 9:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 1:25 org-element: headline's :title is sometimes string, sometimes list Hraban Luyat
2023-08-23 9:49 ` Ihor Radchenko [this message]
2023-08-23 15:01 ` Hraban Luyat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jztm6qcd.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=hraban@0brg.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).