gpt4 book ai didi

org-mode - org-mode 表内的代码块

转载 作者:行者123 更新时间:2023-12-03 17:18:40 25 4
gpt4 key购买 nike

我爱org-tables ,我用它们来记录各种事情。我现在正在为 Nix 记录一些单行代码(在阅读了 Domen Kožar 的 excellent guide 后,在 this year's EuroPython 给出),我遇到了一些问题:

* NIX Oneliners

|------------------+---------------------------------------------+------------------------------|
| DATE | COMMAND | DESCRIPTION |
|------------------+---------------------------------------------+------------------------------|
| <2014-07-24 Thu> | curl -L http://git.io/nix-install.sh § bash | Install nix |
| <2014-07-24 Thu> | nix-env -qaP § grep python3-3 | search for python3-3 package |
|------------------+---------------------------------------------+------------------------------|

这些命令实际上应该是 curl -L http://git.io/nix-install.sh | bashnix-env -qaP | grep python3-3 ,但由于管道破坏了整个事情,我需要使用另一个字符(在这种情况下 § )

我的问题是:我怎样才能告诉 org-mode 在区域中获取文本 字面意思 ?我不想 use a escape sequence for the pipe ,因为我想从我的文档中轻松复制粘贴到 shell。

我想要的是类似于markdown中的代码块:
`do | not | care | about | this`

这在 org-mode 中是否存在? ?

编辑

事件 using = this | trick =在表格内不起作用。

最佳答案

你不能这样做:你不能逃避“|”表条目中的字符:您能做的最好的事情就是用看起来像它的东西替换它。
ML 上有几个关于这个的问题,最好的答案似乎是 #xa6 (¦) 处的 Unicode 字符 - 参见例如this message和封闭的线程。

但是,您可以在表中存储指向代码块的链接。在代码块内,您可以有任意代码,因此那里的特殊字符没有问题,并且作为奖励,您可以执行代码块。

像这样的东西:

* Table of code blocks

| Name | Code block |
|------+------------|
| foo | [[foo][foo]] |
| bar | [[bar][bar]] |


#+name: foo
#+begin_src bash
echo "Foo"
#+end_src

#+RESULTS: foo
: Foo

#+name: bar
#+begin_src bash
echo "Bar"
#+end_src

关于org-mode - org-mode 表内的代码块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24933135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com