Progit 简单粗暴的页面生成工具

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

#!/bin/bash

if [ -e out ]; then
	rm -r out
fi

mkdir out
mkdir out/figures

if [ -d figures ]; then
	for i in figures/*; do
		cp $i out/${i/-tn/}
	done
else
	echo figures folder not found
	exit 404
fi

if [ ! -d zh ]; then
	echo zh folder not found
	exit 404
fi

cat > /tmp/header <<META_HEADER
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="Generator" content="progit-gen,by Neo">
	<title>Progit</title>
	<style type="text/css">div {text-align: center;}</style>
</head>
<body>
META_HEADER

cat > /tmp/footer <<META_FOOTER
</body>
</html>
META_FOOTER

pushd zh > /dev/null
for i in `find . -name *.markdown`; do
	d=`dirname $i`
	cat /tmp/header > $d.html
	cat $i | awk '{if($1 == "Insert") {print "<div><img src=\"figures/" $2 "\">"; getline; print "<p>"$0"</p></div>\n"; getline} else {print $0}}' | markdown >> $d.html
	cat /tmp/footer >> $d.html
	echo -n ". "
done
mv *.html ../out/
popd > /dev/null

rm /tmp/header /tmp/footer
echo "."

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

Centos系统之Shell编程基础知识
从Export理解Shell环境和变量生存期
linux shell数组变量、类型及规则
Centos编程Shell基本工作原理方案
Centos操作系统编程之Shell 问答录
rsync-linux备份脚本