I'm writing some documentation in Markdown, and creating a separate file for each section of the doc. I would like to be able to convert all the files to HTML in one go, but I can't find anyone else who has tried the same thing. I'm on a Mac, so I would think a simple bash script should be able to handle it, but I've never done anything in bash and haven't had any luck. It seems like it should be simple to write something so I could just run:
我正在Markdown中编写一些文档,并为文档的每个部分创建一个单独的文件。我希望能够一次性将所有文件转换为HTML,但我找不到其他人尝试过同样的事情。我在Mac上,所以我认为一个简单的bash脚本应该能够处理它,但我从未在bash中做过任何事情并且没有任何运气。似乎写一些东西应该很简单,所以我可以运行:
markdown-batch ./*.markdown
Any ideas?
4 个解决方案
#1
18
This is how you would do it in Bash.
这就是你在Bash中的表现。
for i in ./*.markdown; do perl markdown.pl --html4tags $i > $i.html; done;
Of course, you need the Markdown script.
当然,您需要Markdown脚本。
#2
46
Use pandoc — it's a commandline tool that lets you convert from one format to another. This tool supports Markdown to HTML and back.
使用pandoc - 它是一个命令行工具,可以让您从一种格式转换为另一种格式。此工具支持Markdown to HTML和back。
E.g. to generate HTML from Markdown, run:
例如。要从Markdown生成HTML,请运行:
pandoc -f markdown index.md > index.html
#3
1
I use this in a .bat file:
我在.bat文件中使用它:
@echo off
for %i in (*.txt) python markdown.py "%i"
#4
-1
// using Bash in mac
//在mac中使用Bash
for i in *.md; do asciidoc $i; done;
#1
18
This is how you would do it in Bash.
这就是你在Bash中的表现。
for i in ./*.markdown; do perl markdown.pl --html4tags $i > $i.html; done;
Of course, you need the Markdown script.
当然,您需要Markdown脚本。
#2
46
Use pandoc — it's a commandline tool that lets you convert from one format to another. This tool supports Markdown to HTML and back.
使用pandoc - 它是一个命令行工具,可以让您从一种格式转换为另一种格式。此工具支持Markdown to HTML和back。
E.g. to generate HTML from Markdown, run:
例如。要从Markdown生成HTML,请运行:
pandoc -f markdown index.md > index.html
#3
1
I use this in a .bat file:
我在.bat文件中使用它:
@echo off
for %i in (*.txt) python markdown.py "%i"
#4
-1
// using Bash in mac
//在mac中使用Bash
for i in *.md; do asciidoc $i; done;