我想使用emacs的org-mode为我的Jekyll驱动的博客写博客文章。阅读Using org to Blog with Jekyll时,通常会将前面的内容放在一个#+BEGIN_HTML / #+END_HTML块中,它会原封不动地传递前面的内容。
但是,使用org-edit-special (C-c ')时,您最终会在特殊的编辑缓冲区中使用html-mode。切换到yaml-mode不起作用,因为您不能从特殊编辑模式返回。
有没有什么方法可以在yaml-mode中编辑这个前置内容,而不需要求助于将整个缓冲区更改为yaml-mode,然后返回到org-mode?
发布于 2015-05-26 13:16:39
这是我想出来的:
为yaml创建babel execute函数:
(defun org-babel-execute:yaml (body params) body)然后我可以做我想做的事:
#+STARTUP: showall expand
#+options: toc:nil
#+begin_src yaml :exports results :results value html
---
layout: post
title: test post with yaml source block frontmatter
gallery:
path: abc123
images:
- blah.png
- bloo.png
---
#+end_src
* hello world这正是我在导出markdown文件时想要的结果。
发布于 2015-05-25 11:23:10
您可以创建一个自定义命令,其中html与yaml-mode相关联。
(defun org-edit-html-export-block-as-yaml ()
(interactive)
(let ((org-src-lang-modes '(("html" . yaml))))
(org-edit-export-block)))
(define-key org-mode-map YOUR-KEY 'org-edit-html-export-block-as-yaml)我已经在(组织模式的开发版本)上进行了测试
#+begin_html
key: 3
#+end_html而且它似乎工作得很好。
https://stackoverflow.com/questions/30430346
复制相似问题