emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* example or source blocks with captions
@ 2011-04-27 15:57 Neilen Marais
  2011-04-27 19:36 ` Sébastien Vauban
  2011-04-27 21:21 ` Thomas S. Dye
  0 siblings, 2 replies; 6+ messages in thread
From: Neilen Marais @ 2011-04-27 15:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Is it possible to caption a #+begin_src or #+begin_example block? Doing

#+CAPTION: dipole_analytical_balanis.mac
#+begin_example
....
#+end_example

doesn't seem to do the trick. I would find this useful to include
suggested filenames when quoting source on a web page.

Thanks
Neilen

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: example or source blocks with captions
@ 2011-04-30  5:00 Jambunathan K
  0 siblings, 0 replies; 6+ messages in thread
From: Jambunathan K @ 2011-04-30  5:00 UTC (permalink / raw)
  To: emacs-orgmode


(Forwarding it - Looks like the original mail didn't make it's way to
the list)

> Hi Neilen,
>
> Neilen Marais wrote:
>> Is it possible to caption a #+begin_src or #+begin_example block? Doing
>>
>> #+CAPTION: dipole_analytical_balanis.mac
>> #+begin_example
>> ....
>> #+end_example
>>
>> doesn't seem to do the trick. I would find this useful to include
>> suggested filenames when quoting source on a web page.
>
> Would such block be better for you?
>
> #+srcname: dipole_analytical_balanis.mac
> #+begin_src mac
> ....
> #+end_src
>
> The source name should be exported in HTML. If not, this is a feature.[1]
>

A cursory look suggests that

org-export-format-source-code-or-example takes caption as an arg. This
is used only if htmlize or org-export-latex-listings is configured by
the user - Both of these are not part of factory settings and wouldn't
work out of the box. (Seems like the situation could be improved)

ASCII export always exports a caption without fail.

So if I export

* Source Block
** Emacs Lisp Block

--8<---------------cut here---------------start------------->8---
#+CAPTION: HelloWorldCaption
#+srcname: HelloWorldSrcName
#+begin_src emacs-lisp
  (defun helloworld () 
    ""
    (message "hello world"))
#+end_src  
--8<---------------cut here---------------end--------------->8---

I get something like 

--8<---------------cut here---------------start------------->8---
1 Source Block 
---------------

1.1 Emacs Lisp Block 
=====================


  (defun helloworld () 
    ""
    (message "hello world"))
--8<---------------cut here---------------end--------------->8---

meaning that captions are not possibly passed into
org-export-format-source-code-or-example.

A cursory look at org-export-attach-captions-and-attributes where
('org-caption text property is added) suggests that captions are not
getting associated with the src blocks.

In summary, there seems to be a clear intent to attach a caption to
example or source blocks but somehow things are turning out otherwise.

Jambunathan K.

> Best regards,
>   Seb
>
> Footnotes:
>
> [1] I know for sure it does when the block has "grounded" parameters (ie, with
> a given value).

-- 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-30  5:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 15:57 example or source blocks with captions Neilen Marais
2011-04-27 19:36 ` Sébastien Vauban
2011-04-30  5:00   ` Jambunathan K
2011-04-27 21:21 ` Thomas S. Dye
2011-04-28  7:46   ` Sébastien Vauban
  -- strict thread matches above, loose matches on Subject: below --
2011-04-30  5:00 Jambunathan K

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