DONE Suitable export of #+srcname and #+resname lines

  • State "DONE" from "STARTED" 2010-02-11 Thu 09:46
  • State "STARTED" from "TODO" 2010-01-04 Mon 15:05
  • State "TODO" from "STARTED" 2010-01-04 Mon 09:31

update – exporting arguments with source names

We are now exporting arguments with source-block names and wrapping source-code blocks and names in div which is given the org-src-container class. This allows for styling of the name and block, and for explicit association of the name and block using css like the following which we will apply here with an HTML block

#+begin_html
  <style type="text/css">
    .org-src-container {
    border-left: 4px solid gray; /* gray bar offsetting code and name */
    padding: 0.5em 0.5em 0.5em 1em; }
    .org-src-container pre {
      margin-left: 1em; }        /* indentation of code blocks w/names */
  </style>
#+end_html

So, for example the following raw org-mode text

#+source: fibonacci
#+begin_src emacs-lisp :var input=0
  (defun fib (n)
    (if (> n 1)
        (+ (fib (- n 1)) (fib (- n 2)))
        1))
  (fib input)
#+end_src

#+results: fibonacci
: 1

now applying our Fibonacci function

#+call: fibonacci(input=5)

#+results: fibonacci(input=5)
: 8

exports to the following html

(defun fib (n)
  (if (> n 1)
      (+ (fib (- n 1)) (fib (- n 2)))
      1))
(fib input)

now applying our Fibonacci function

older

The current fix here takes the simplest possible approach. The name of a source-code block is placed in the org-caption text property and `org-export-format-source-code-or-example' then reads this property and adds the name to the export.

So the following source-code block

#+source: square
#+begin_src emacs-lisp :var input=1
  (* input input)
#+end_src

exports to the following html

(* input input)

which is the following raw html

<label class="org-src-name">square</label>
<pre class="src src-emacs-lisp">
<span style="color: #7f7f7f;">(</span>* input input<span style="color: #7f7f7f;">)</span>
</pre>

and the following raw latex

\lstset{language=Lisp}\begin{lstlisting}[title={square}]
(* input input)
\end{lstlisting}

There is much room here for stylistic improvement and hopefully this initial implementation will spur discussion/suggestions for how to improve the appearance and content of these exported source-names.