input_file = codecs.open(in_file, mode="r", encoding="utf-8") text = input_file.read() html = markdown.markdown(text)
#!/usr/bin/env python # -*- coding: utf-8 -*- # 使用方法 python markdown_convert.py filename import sys import markdown import codecs css = ''' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> <!-- 此处省略掉markdown的css样式,因为太长了 --> </style> ''' def main(argv): name = argv[0] in_file = '%s.md' % (name) out_file = '%s.html' % (name) input_file = codecs.open(in_file, mode="r", encoding="utf-8") text = input_file.read() html = markdown.markdown(text) output_file = codecs.open(out_file, "w",encoding="utf-8",errors="xmlcharrefreplace") output_file.write(css+html) if __name__ == "__main__": main(sys.argv[1:])
#!/bin/bash
NAME='测试文档'
## 更新代码
svn update
## 删除html文件
if [ -f "$NAME.html" ];then
rm "$NAME.html"
fi
## 生成html
if [ -f "$NAME.md" ];then
python markdown_convert.py $NAME
fi
## 生成html目录
if [ ! -d "html" ];then
mkdir "html"
fi
## 拷贝html文件
if [ -f "$NAME.html" ];then
mv -f "$NAME.html" "html/"
fi
## 开启web服务器
PID=`ps aux | grep 'python -m SimpleHTTPServer 8080' | grep -v 'grep' | awk '{print $2}'`
if [ "$PID" = "" ];then
cd html
nohup python -m SimpleHTTPServer 8080 &
echo 'start web server'
else
echo 'already start'
fi
## 更新文档 */10 * * * * cd /home/xxx/doc; sh markdown2web.sh > /dev/null 2>&1
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有