emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Using babel to generate org syntax for export
@ 2014-01-14  3:24 James Harkins
  2014-01-14  3:39 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: James Harkins @ 2014-01-14  3:24 UTC (permalink / raw)
  To: orgmode

Hi,

Got a question that's not easy to search online.

I want to use an org table to define glossary entries for LaTeX. I have my 
table[1], and I have a src block[2] that reads the table and produces the 
right syntax[3]. This is already pretty helpful -- I can C-c C-c the source 
block and manually copy/paste the generated syntax into the org file that I 
will then export. 

But... I want babel to do that for me automatically. I'm almost there, but:

The resulting string is put into a verbatim environment -- which is not 
right for this case. I need the string to be inserted as if it were org 
syntax ("#+LATEX_HEADER" and all) that I typed by hand, and then ox-latex 
would process it like any other LaTeX header.

I've tried both ":results value" and ": results output" but the verbatim 
environment is always there.

A quick glance at ob-core.el seems to indicate that this behavior is 
hardcoded. That's... frustrating: spend 2-3 hours to get this far and then 
find that babel says, "No, you can't do that, actually."

So, I'm at the end of the energy I have left to test various approaches. 
What's the best approach? I'm guessing, apply a filter to remove the 
begin/end verbatim lines. But maybe there's a magic switch in babel?

For reference:

[1] input file, nearly minimal example
[2] actual result of C-c C-e l L (removing preamble)
[3] desired result

hjh

[1]
* UGens   :noexport:
#+name: ugens01
| Type | Term     | Description         | Arguments   |
|------+----------+---------------------+-------------|
| Osc  | SinOsc   | Sinewave oscillator | freq, phase |

#+name: makegloss
#+begin_src emacs-lisp :var tbl=ugens01 :exports results :results value
(let ((str ""))
  (pop tbl)
  (pop tbl)
  (while tbl
    (let ((item (car tbl)))
      (pop item)
      (setq str (concat str (format 
"\\newglossaryentry{%s}{type=ugen,name={%s},description={%s. Inputs: 
(%s)}}\n"
  		   (car item)
  		   (pop item)
  		   (pop item)
  		   (car item))))
      (setq tbl (cdr tbl))))
  str)
#+end_src

* Test
#+call: makegloss
#+results: makegloss

[2]
\section{Test}
\label{sec-1}
\begin{verbatim}
\newglossaryentry{SinOsc}{type=ugen,name={SinOsc},description={Sinewave 
oscillator. Inputs: (freq, phase)}}
\end{verbatim}

[3]
\section{Test}
\label{sec-1}
\newglossaryentry{SinOsc}{type=ugen,name={SinOsc},description={Sinewave 
oscillator. Inputs: (freq, phase)}}

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

* Re: Using babel to generate org syntax for export
  2014-01-14  3:24 Using babel to generate org syntax for export James Harkins
@ 2014-01-14  3:39 ` Eric Schulte
  2014-01-14  7:05   ` James Harkins
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2014-01-14  3:39 UTC (permalink / raw)
  To: James Harkins; +Cc: orgmode

James Harkins <jamshark70@gmail.com> writes:

> Hi,
>
> Got a question that's not easy to search online.
>
> I want to use an org table to define glossary entries for LaTeX. I have my 
> table[1], and I have a src block[2] that reads the table and produces the 
> right syntax[3]. This is already pretty helpful -- I can C-c C-c the source 
> block and manually copy/paste the generated syntax into the org file that I 
> will then export. 
>
> But... I want babel to do that for me automatically. I'm almost there, but:
>
> The resulting string is put into a verbatim environment -- which is not 
> right for this case. I need the string to be inserted as if it were org 
> syntax ("#+LATEX_HEADER" and all) that I typed by hand, and then ox-latex 
> would process it like any other LaTeX header.
>
> I've tried both ":results value" and ": results output" but the verbatim 
> environment is always there.
>

Have you tried ":results raw" or ":results org", take a look at the
manual page on the results header argument.

Best,

>
> A quick glance at ob-core.el seems to indicate that this behavior is
> hardcoded. That's... frustrating: spend 2-3 hours to get this far and then 
> find that babel says, "No, you can't do that, actually."
>
> So, I'm at the end of the energy I have left to test various approaches. 
> What's the best approach? I'm guessing, apply a filter to remove the 
> begin/end verbatim lines. But maybe there's a magic switch in babel?
>
> For reference:
>
> [1] input file, nearly minimal example
> [2] actual result of C-c C-e l L (removing preamble)
> [3] desired result
>
> hjh
>
> [1]
> * UGens   :noexport:
> #+name: ugens01
> | Type | Term     | Description         | Arguments   |
> |------+----------+---------------------+-------------|
> | Osc  | SinOsc   | Sinewave oscillator | freq, phase |
>
> #+name: makegloss
> #+begin_src emacs-lisp :var tbl=ugens01 :exports results :results value
> (let ((str ""))
>   (pop tbl)
>   (pop tbl)
>   (while tbl
>     (let ((item (car tbl)))
>       (pop item)
>       (setq str (concat str (format 
> "\\newglossaryentry{%s}{type=ugen,name={%s},description={%s. Inputs: 
> (%s)}}\n"
>   		   (car item)
>   		   (pop item)
>   		   (pop item)
>   		   (car item))))
>       (setq tbl (cdr tbl))))
>   str)
> #+end_src
>
> * Test
> #+call: makegloss
> #+results: makegloss
>
> [2]
> \section{Test}
> \label{sec-1}
> \begin{verbatim}
> \newglossaryentry{SinOsc}{type=ugen,name={SinOsc},description={Sinewave 
> oscillator. Inputs: (freq, phase)}}
> \end{verbatim}
>
> [3]
> \section{Test}
> \label{sec-1}
> \newglossaryentry{SinOsc}{type=ugen,name={SinOsc},description={Sinewave 
> oscillator. Inputs: (freq, phase)}}
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Re: Using babel to generate org syntax for export
  2014-01-14  3:39 ` Eric Schulte
@ 2014-01-14  7:05   ` James Harkins
  0 siblings, 0 replies; 3+ messages in thread
From: James Harkins @ 2014-01-14  7:05 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

On Jan 14, 2014 11:41 AM, "Eric Schulte" <schulte.eric@gmail.com> wrote:
> Have you tried ":results raw" or ":results org", take a look at the
> manual page on the results header argument.

Missed that - thanks for the pointer. I looked pretty carefully at the page
on "Evaluating code blocks," which says basically nothing about controlling
the result format (and also doesn't link to the header argument that would
explain it).

"raw" is probably the one I need. Thanks again.

hjh

[-- Attachment #2: Type: text/html, Size: 635 bytes --]

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

end of thread, other threads:[~2014-01-14  7:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-14  3:24 Using babel to generate org syntax for export James Harkins
2014-01-14  3:39 ` Eric Schulte
2014-01-14  7:05   ` James Harkins

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