理解 VIM:自动(自动和神奇)将 markdown 转换为 html
Understanding VIM: Automagically (Automatic and Magical) transform markdown to html
我正在研究 vim 及其内部工作原理。在网上闲逛时无意中发现了这个article,其中一节讨论了如何自动将markdown转换为html:
“See, master,” he said, “I have nearly finished the Vim macros that translate Markdown into HTML. My functions interweave, my parser is a paragon of efficiency, and the results nearly flawless. I daresay I have mastered Vimscript, and my work will validate Vim as a modern editor for the enlightened developer! Have I done rightly?”
Master Wq read the acolyte’s code for several minutes without saying anything. Then he opened a Markdown document, and typed:
:%!markdown
HTML filled the buffer instantly. The acolyte began to cry.
我通过首先安装 markdown 来尝试这个,sudo apt-get install -y markdown
...在打开 vim 并输入一些 markdown 之后:
# Hello
This is just a test
public class Main {
public static void main(String[] args) {
}
}
然后输入::%!markdown
,突然出现:
<h1>Hello</h1>
<p>This is just a test</p>
<pre><code> public class Main {
public static void main(String[] args) {
}
}
</code></pre>
我的观察:markdown
解析markdown并输出html,所以谜底就在:%!
,谁能赐教一下?
顺便说一句,Vim 很棒..你应该试试!
过滤是一种极其常见的 unix 模式,它包括在将命令的输出传递给另一个命令之前对其进行操作。
:%!markdown
表示“打开一个子shell,将当前缓冲区的全部内容传递给markdown
程序的stdin
并替换整个缓冲区从它的 stdout
.
出来的任何东西
我正在研究 vim 及其内部工作原理。在网上闲逛时无意中发现了这个article,其中一节讨论了如何自动将markdown转换为html:
“See, master,” he said, “I have nearly finished the Vim macros that translate Markdown into HTML. My functions interweave, my parser is a paragon of efficiency, and the results nearly flawless. I daresay I have mastered Vimscript, and my work will validate Vim as a modern editor for the enlightened developer! Have I done rightly?”
Master Wq read the acolyte’s code for several minutes without saying anything. Then he opened a Markdown document, and typed:
:%!markdown
HTML filled the buffer instantly. The acolyte began to cry.
我通过首先安装 markdown 来尝试这个,sudo apt-get install -y markdown
...在打开 vim 并输入一些 markdown 之后:
# Hello
This is just a test
public class Main {
public static void main(String[] args) {
}
}
然后输入::%!markdown
,突然出现:
<h1>Hello</h1>
<p>This is just a test</p>
<pre><code> public class Main {
public static void main(String[] args) {
}
}
</code></pre>
我的观察:markdown
解析markdown并输出html,所以谜底就在:%!
,谁能赐教一下?
顺便说一句,Vim 很棒..你应该试试!
过滤是一种极其常见的 unix 模式,它包括在将命令的输出传递给另一个命令之前对其进行操作。
:%!markdown
表示“打开一个子shell,将当前缓冲区的全部内容传递给markdown
程序的stdin
并替换整个缓冲区从它的 stdout
.