功能 :读入文本内容转化为HTML
import sys
def lines(file):
for line in file:
yield line
yield '\n'
def blocks(file):
block = []
for line in lines(file):
if line.strip():
block.append(line)
elif block:
yield ''.join(block).strip()
block = []
import sys,re
from util import *
print '
...'title = True
for block in blocks(sys.stdin):
block = re.sub(r'\*(.+?)\*',r'\1',block)
if title:
print '
'
print block
print ''
title = False
else:
print '
'
print block
print '
'print ''