import sys import os import re sys.path.append(".") import html2sgml_map patternInsertPos=re.compile(r'.*<BODY\s+[^>]*>',re.S) InsertHTML="""<div style="text-align:right"> <a style="margin : 0px 0px 0px 10px;" href="https://github.com/postgres-cn/pgdoc-cn/issues/new" target="_blank" title="在Github上报告问题(请注明问题内容及所在章节)">问题报告</a> <a style="margin : 0px 0px 0px 10px;" href="https://github.com/postgres-cn/pgdoc-cn/edit/master/postgresql/doc/src/sgml/{0}" target="_blank" title="直接在Github上纠错本页面">纠错本页面</a> </div>""" sgmlDir="../build/doc/src/sgml" htmlDir=os.path.join(sgmlDir,"html") htmlOutputDir=os.path.join("html_out") html2sgmlDict=html2sgml_map.getHtml2sgmlDict(sgmlDir) if not os.path.exists(htmlOutputDir): os.mkdir(htmlOutputDir) # copy stylesheet.css open(os.path.join(htmlOutputDir,"stylesheet.css"), "wb").write(open(os.path.join(sgmlDir,"stylesheet.css"), "rb").read()) def process(file): filename=os.path.basename(file) fin=open(file,"r",encoding='GBK') fout=open(os.path.join(htmlOutputDir,filename),"w",encoding='UTF-8') content=fin.read() content=content.replace('CONTENT="text/html; charset=gbk"','CONTENT="text/html; charset=utf-8"') sgmlfile=html2sgmlDict.get(filename.lower())
import sys import os import re import argparse sys.path.append(".") import html2sgml_map InsertHTML2 = """<div style="text-align:center"> <a style="margin : 0px 0px 0px 0px;" href="https://www.aliyun.com/product/rds/postgresql" target="_blank" ><img src="/docs/pic/tailbar.jpg" /></a> </div> """ sgmlDir = "../build/doc/src/sgml" htmlDir = os.path.join(sgmlDir, "html") htmlOutputDir = os.path.join("html_out") html2sgmlDict = html2sgml_map.getHtml2sgmlDict(sgmlDir) def generate_navigate_bar_HTML(current_version, master_version, all_versions): html = """<div class="preheader"> <div style="float: left"> """ # 添加所有版本的导航连接 for v in all_versions.split(','): if v == current_version: html += '<span style="margin : 0px 5px 0px 5px;">{0}</span>\n'.format( v) else: html += '<a style="margin : 0px 5px 0px 5px;" href="/docs/{0}/{{0}}" target="_top">{0}</a>\n'.format( v, v)