Export code block names in cweb or noweb style?

笑着哭i 提交于 2019-12-21 05:45:12

问题


When writing a literate program in Org mode, exporting is analogous to weaving in earlier literate programming tools such as cweb or noweb. Those tools would add a code block name to the woven (exported) output. In Org mode, it would look something like this:

Org file:

#+NAME: mycodeblock
#+BEGIN_SRC language
[Source code here]
#+END_SRC

Exported output:

<mycodeblock>=
[Source code here]

I am wondering if there is any support in Org mode for exporting names of code blocks in this style. If not, is there any way to at least output the name of the code block as a label of some kind?

I have seen hints that names of code blocks can be exported, but I have failed to find the exact syntax.


回答1:


You could experiment with:

;; template used to export the body of code blocks
(setq org-babel-exp-code-template
      ;; (concat "\n=%name=:\n"
              org-babel-exp-code-template)
      ;; )
)

Though, that's not as nice as the results of NuWeb / NoWeb; see http://lists.gnu.org/archive/html/emacs-orgmode/2009-12/msg00170.html for a comparison of them vs Org (though the PDF links aren't accessible anymore).



来源:https://stackoverflow.com/questions/24073612/export-code-block-names-in-cweb-or-noweb-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!