最后一部分是关于导出属性的讨论。这是整个讨论中比较复杂的部分,围绕如何使用 :export 属性来精细控制 ISB 在不同导出后端中的行为。
在最初的方案中,JMM 设想通过 :export 属性指定需要导出到的后端,name+ 表示完整导出(包含标记),name* 表示仅导出内容,noexport 表示不导出任何内容。@foo[:export latex+ odt* html*]{...} 的意思是完整导出到 LaTeX,仅导出内容到 ODT 和 HTML。
Max 提出了更高的要求:处理那些未指定后端的内容。现有的导出片段机制要求为每个目标后端显式编写代码,比如 @@latex:...@@ 和 @@html:...@@ 。如果想要让内容以特定方式导出到 LaTeX 和 HTML,而对所有其他未指定的后端采用一个简单的默认格式则难以实现。另一个问题是,Org-mode 的导出后端之间可能存在继承关系,Max 希望能明确指定为某一后端(比如 latex)设定的规则是仅适用于它本身还是用于所有派生出来的后端。
对此,JMM 认为通过定义别名可以部分避免使用多个导出片段的情况,比如:
@@latex:\textbf{\LaTeX() formatting}@@@@html:<strong>HTML formatting</strong>@@
可以写成
#+options: inline-special-block-aliases:(("strong" :latex-command textbf :html-tag strong :export "latex+ html+ odt*" ))
@strong{formatting}
or even:
@strong{@@latex:\latex{}: @@@@html:HTML: @@ formatting}
另外,为了避免列出所有的后端,JMM 表示可以考虑添加一个 rest 选项,就像 :export "latex+ html+ rest*" 这样。对于导出设定是否应该应用于某个后端的派生后端,JMM 没有明确的态度。考虑到 rest 实际上可以作为后端名,Stefan Nobis 建议 使用 :others 来表示没有显式提到的所有导出后端,另外可以考虑将 + 作为默认行为,这样可以省区一个符号。JMM 实现了 + 改进并给出了一些例子:
Examples:
@foo[:export noexport]{lorem ipsum dolor}
==> does not export anything
@foo[:export contents]{lorem ipsum dolor}
==> only contents
@foo[:export latex]{lorem ipsum dolor}
==> exports only to LaTeX
@foo[:export latex odt* html*]{lorem ipsum dolor}
==> exports everything to LaTeX, but to odt and HTML only the content
@foo[:export latex* rest]{lorem ipsum dolor}
==> content to LaTeX but full export to the rest of the backends
@foo[:export latex rest*]{lorem ipsum dolor}
==> the opposite of the above.
Max 指出 JMM 的规则无法解决一个复杂的实际用例:如何排除特定的后端(例如,不向 HTML 导出 YouTube 链接,因为 HTML 已经使用嵌入式播放器,此处有详细解释)而将内容导出到所有其他后端(EPUB, LaTeX, ODT, text 等)。为了实现这种“排除”逻辑和更精细的控制,Max 建议放弃使用 noexport 和 rest 等可能与后端名称混淆的字符串,转而引入特定的操作符,例如使用 -、* 或 + 等字符来明确表达“不导出到此后端及其派生后端”或“仅导出内容”等语义。
在 JMM 给出的新方案后,他与 Max 经过一些讨论后得到了以下导出规则:
* 仅导出内容
- 不导出
= 对未提及的后端进行完整导出
*= 对未提及的后端进行仅内容导出
=- 不导出到未提及的后端
(老实说,看到这里我已经感觉到了这玩意在越变越复杂)
对于这一方案,Max 指出 - 是一个有效的后端名称或后端名称的有效结尾字符。如果单独使用 - 或将它作为后缀表达不导出的语义,这可能与实际的后端名称产生冲突。另一个问题是如果为多个后端·指定了 = 规则,它的效果并不明确。此外,规则仍然不足以表达对派生后端的控制。在 JMM 回复之前有个语法讨论的小插曲,Ihor 提议直接使用 sexp 来表达导出规则,不过 Max 表示重点是在约束派生后端上,以及可能没有直接可用的函数来解释可能的 sexp 描述。
在 JMM 的回复中,他承认了没有考虑到 - 可能与有效的后端名称冲突的问题。如果用户只想导出到一个后端,必须输入冗长的 :export backend=-,理想状态是只输入 :export backend,但他目前无法实现这一要求。在考虑了派生后端的相关问题后,JMM 整理并提出了下一版简化语法的设想:* 表示导出内容,/ 表示跳过,. 表示不导出派生后端,= 表示完整导出此后端和派生后端。在这一规则下:
:export latex* 表示对 latex 仅导出内容,其余后端导出全部
:export latex/ 表示不导出到 latex
:export latex. 表示不导出到 latex 的派生后端
:export latex .(注意空格)表示对 latex 进行全部导出且不导出到所有其他后端的派生后端
(越来越复杂了)
在这一子话题下的后续内容是对实现的一些讨论,此处略过。
在 24 年 4 月,在详细阅读相关讨论后,Ihor 极其详尽地提出了一些疑问和提案。对此 JMM 表示最近有点忙可能要点时间:
https://lists.gnu.org/archive/html/emacs-orgmode/2024-04/msg00178.html
Hi, Ihor. Thanks for all your comments. I will try to answer each of the
questions you have raised. Let's see if I can find a space next week...
The latest added to the branch are Maxim's proposals (and code) for
backend control. See this thread:
Max 此处给出了一些讨论上下文: Re: Experimental public branch for inline special blocks
这一话题的最后一次讨论日期是在 24 年的 7 月,JMM 表示其他人可以接手他的工作。
https://lists.gnu.org/archive/html/emacs-orgmode/2024-07/msg00255.html
Juan Manuel Macías <[email protected]> writes:
> ... until
> September I will not be able to participate actively or continuously on
> the list.
No problem.
I just wanted to make sure that this is not forgotten.
> Of course, if someone wants to actively collaborate in the development
> of this branch, I have no problem. If necessary, I also have no
> objection to moving the repository to another more ‘open’ place (in Gitlab
> it is necessary to have an account to collaborate).
+1
This is an important feature that should be added sooner or later to
address numerous edge cases in the Org markup.
On my side, it is not on the very top of the priorities, so I am happy
that Juan is working on it. If anyone else wants to help, it will be
very welcome as well.