Re: [O] example or source blocks with captions

2011-04-30 Thread Jambunathan K


Sébastien Vauban wxhgmqzgwmuf-genee64ty+gs+fvcfc7...@public.gmane.org
writes:

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

-- 




Re: [O] example or source blocks with captions

2011-04-29 Thread Jambunathan K

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

-- 



Re: [O] example or source blocks with captions

2011-04-27 Thread Sébastien Vauban
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?

--8---cut here---start-8---
#+srcname: dipole_analytical_balanis.mac
#+begin_src mac

#+end_src
--8---cut here---end---8---

The source name should be exported in HTML. If not, this is a feature.[1]

Best regards,
  Seb

Footnotes:

[1] I know for sure it does when the block has grounded parameters (ie, with
a given value).
-- 
Sébastien Vauban




Re: [O] example or source blocks with captions

2011-04-27 Thread Thomas S. Dye

Aloha Neilen Marais,

A while back I took a stab at an overly ambitious project that I've  
subsequently dropped.  In that project I did manage to establish  
captions that work with org-special-blocks.  What follows is a cut and  
paste job from the bones of the project that might help you solve the  
problem of captioning constructs other than figures and tables.  It  
was aimed primarily at LaTeX export, but I seem to recall that it  
worked for html as well.


All the best,
Tom

This link establishes a caption that works with both LaTeX and html
and can be used to mark blocks that Org-mode doesn't recognize by
default.  Note that you currently have to enter these links by hand
and not with the usual =org-insert-link= function, which doesn't allow
spaces in the =PATH= argument.

#+BEGIN_listing
# caption-link-type
#+source: define-caption-link
#+begin_src emacs-lisp :exports code
  (org-add-link-type
   caption nil
   (lambda (path desc format)
 (cond
  ((eq format 'html)
   (format span class=\caption\%s/span desc))
  ((eq format 'latex)
   (format \\caption[%s]{%s} path desc)
#+end_src
[[caption:A new caption link type][A new caption link type.]]
# fig:caption-link
#+END_listing

Block-level markup is accomplished with the help of the
[[latex:package][org-special-blocks]] package.  It is used in this  
file to wrap the
[[latex:progstruct][listing]] environment defined by the  
[[latex:package][minted]] package around a source code

block to get a floating listing in the LaTeX document.  LaTeX will
keep track of floating listings and will also prepare a list of
listings that can be placed between the table of contents and the
first section of the article.  [[latex:classfile][Org-article]] makes  
the [[latex:progstruct][listing]]
environment available with the [[latex:package][listings]] package, as  
well, so this

facility can be used regardless of the package chosen to highlight
syntax and typeset source code listings.

Use a construct like this to wrap the source block in a  
[[latex:progstruct][listing]]

environment.  Typically, you will want to include a figure caption and
a label for cross referencing.  This can be done with a =#+LATEX:= line.

 : #+BEGIN_listing
 :  source block
 : #+LATEX: \caption{The caption.}\ref{fig:src_blk}
 : #+END_listing

To use this facility, you'll need to load [[latex:package][org-special- 
blocks]] (Listing

\ref{fig:org-special-blocks}).  This code can go in =.emacs=, or you
can load it for the session by executing the following source code
block with =C-c C-c=.

#+BEGIN_listing
#+source: special-blocks
#+begin_src emacs-lisp :exports code :results silent
  (require 'org-special-blocks)
#+end_src
[[caption:Require org-special-blocks][Require org-special-blocks.]]
# fig:org-special-blocks
#+END_listing

The [[latex:package][org-special-blocks]] package leaves it up to the  
user to see that

the HTML output is styled correctly.  A line of code like Listing
\ref{fig:css}, or something similar, when added to the  
[[latex:proglang][Org-mode]]

buffer, styles listings by putting a black box around them.

#+BEGIN_listing
#+source: css
#+begin_src org :exports code
 #+STYLE: style.listing {margin: 1em; padding: 1em; border: 1px  
solid black}/style

#+end_src
[[caption:A simple CSS style for listings][A simple CSS style for  
listings.]]

# fig:css
#+END_listing

On Apr 27, 2011, at 5:57 AM, Neilen Marais wrote:


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