소스 검색

STARTED new results types (org, html, latex)

  added a "raw" or "org" results header
Eric Schulte 16 년 전
부모
커밋
fe7c63b18c
2개의 변경된 파일34개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 1
      lisp/org-babel.el
  2. 30 1
      org-babel.org

+ 4 - 1
lisp/org-babel.el

@@ -522,7 +522,10 @@ silent -- no results are inserted"
         (if (stringp result) ;; assume the result is a table if it's not a string
             (if (member "file" insert)
                 (insert result)
-              (org-babel-examplize-region (point) (progn (insert result) (point))))
+              (if (or (member "raw" insert) (member "org" insert))
+                  (progn (save-excursion (insert result))
+                         (if (org-at-table-p) (org-cycle)))
+                (org-babel-examplize-region (point) (progn (insert result) (point)))))
           (progn
             (insert
              (concat (orgtbl-to-orgtbl

+ 30 - 1
org-babel.org

@@ -225,7 +225,7 @@ Maybe this should be done in backend specific manners.
 
 The listings package may provide for naming a source-code block...
 
-** PROPOSED new results types (org, html, latex)
+** STARTED new results types (org, html, latex)
    Thanks to Tom Short for this recommendation.
 
    - raw or org :: in which case the results are implemented raw, unquoted
@@ -250,6 +250,35 @@ We actually might want to remove the =#+resname= line if the results
 type is org-mode, not sure...  Either way I don't think there is a
 good way to capture/remove org type results.
 
+*** raw
+
+Added a =raw= results header argument, which will insert the results
+of a source-code block into an org buffer un-escaped.  Also, if the
+results look like a table, then the table will be aligned.
+
+#+srcname: raw-table-demonstration
+#+begin_src ruby :results output raw
+  puts "| root | square |"
+  puts "|---"
+  10.times do |n|
+    puts "| #{n} | #{n*n} |"
+  end
+#+end_src
+
+#+resname:
+| root | square |
+|------+--------|
+|    0 |      0 |
+|    1 |      1 |
+|    2 |      4 |
+|    3 |      9 |
+|    4 |     16 |
+|    5 |     25 |
+|    6 |     36 |
+|    7 |     49 |
+|    8 |     64 |
+|    9 |     81 |
+
 ** PROPOSED raise elisp error when source-blocks return errors
 Not sure how/if this would work, but it may be desirable.