stig / ox-jira.el

Org-mode export backend for JIRA markup
129 stars 19 forks source link

Support Org Babel Results #36

Closed microamp closed 6 years ago

microamp commented 7 years ago

Input:

- Some Python example here
  #+BEGIN_SRC python
import operator
result = reduce(operator.add, range(1, 5))
return result
  #+END_SRC

  #+RESULTS:
  : 10

Output:

* Some Python example here
{code:title=|language=none|collapse=false}import operator
result = reduce(operator.add, range(1, 5))
return result
{code}

I think

#+RESULTS:
: 10

can be inside a code snippet. e.g.

{code}
10
{code}
stig commented 6 years ago

The default in Org is for Python snippets to export the code, not the results. (Some other languages are different, e.g. ditaa, where exporting the results is the default.) You can export the results too by adding a property:

- Some Python example here
  #+BEGIN_SRC python :exports both
import operator
result = reduce(operator.add, range(1, 5))
return result
  #+END_SRC

  #+RESULTS:
  : 10

results in

* Some Python example here
{code:title=|language=none|collapse=false}import operator
result = reduce(operator.add, range(1, 5))
return result
{code}
{noformat}
10
{noformat}

and you can also get just the results like so:

- Some Python example here
  #+BEGIN_SRC python :exports results
import operator
result = reduce(operator.add, range(1, 5))
return result
  #+END_SRC

  #+RESULTS:
  : 10

which results in:

* Some Python example here
{noformat}
10
{noformat}

If you specifically want the results to be code rather than "noformat" you can add another property to the code example: :results code, like so:

- Some Python example here
  #+BEGIN_SRC python :exports both :results code
import operator
result = reduce(operator.add, range(1, 5))
return result
  #+END_SRC

  #+RESULTS:
  #+BEGIN_SRC python
  10
  #+END_SRC

It will output the following in JIRA format:

* Some Python example here
{code:title=|language=none|collapse=false}import operator
result = reduce(operator.add, range(1, 5))
return result
{code}
{code:title=|language=none|collapse=false}10
{code}

Does this solve your problem?