emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] How to extract header arguments of a special block?


From: Rasmus
Subject: Re: [O] How to extract header arguments of a special block?
Date: Tue, 20 Jan 2015 02:02:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi,

Marcin Borkowski <address@hidden> writes:

> #+BEGIN_FOO :bar baz qux
> whatever
> #+END_FOO
>
> and I want to extract the value of the header argument "bar" (i.e., the
> string "baz qux" in this case).  How do I do it?

Here's something to get you started.

#+BEGIN_FOO :bar baz qux
whatever
#+END_FOO

#+BEGIN_SRC emacs-lisp
  (goto-char (point-min)) ; to make the example work
  (let ((str (and (search-forward-regexp org-block-regexp nil t)
                  (match-string 3))))
    (when str
      (string-match "[ \t]:\\w+[ \t]+\\([^:]+\\)" str)
      (org-trim (match-string 1 str))))
#+END_SRC

#+RESULTS:
: baz qux

There's a similar "parser" in org-export-expand-include-keyword.  If you
know which argument you are looking for you can replace the \\w+ above.

Hope it helps,
Rasmus

-- 
Send from my Emacs





reply via email to

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