如何在纠结输出中包含 emacs table?

How to include an emacs table in tangled output?

我想在混乱的输出中插入一个 table 作为注释。使用 table 名称会产生空白结果:

#+name: test-data
| type   | amount |
|--------+--------|
| sale   |  31.41 |
| return |   5.92 |

#+BEGIN_SRC python :var data=test-data :tangle test.py :colnames no :noweb yes
  ## Table
  ## <<test-data>>

  [zip(data[0], row) for row in data[1:]]
#+END_SRC

输出:

data=[["type", "amount"], ["sale", 31.41], ["return", 5.92]]
## Table
## 

[zip(data[0], row) for row in data[1:]]

调用参考产生一个 lisp 列表:

#+BEGIN_SRC python :var data=test-data :tangle test.py :colnames no :noweb yes
  ## Table
  ## <<test-data()>>
#+END_SRC

...

## Table
## (("type" "amount") hline ("sale" 31.41) ("return" 5.92))

您可以通过将 table 包装在自己的代码块中来做您想做的事。轻微的缺点是额外的样板和评论中的额外行:

#+name: test-data-block
#+BEGIN_SRC org
#+name: test-data-table
| type   | amount |
|--------+--------|
| sale   |  31.41 |
| return |   5.92 |
#+END_SRC

#+BEGIN_SRC python :var data=test-data-table :tangle test.py :colnames no :noweb yes
  ## Table
  ## <<test-data-block>>

  [zip(data[0], row) for row in data[1:]]
#+END_SRC

而纠结的输出是:

data=[["type", "amount"], ["sale", 31.41], ["return", 5.92]]
## Table
## #+name: test-data-table
## | type   | amount |
## |--------+--------|
## | sale   |  31.41 |
## | return |   5.92 |

[zip(data[0], row) for row in data[1:]]