1 Star 0 Fork 0

lichsword/IGP-DirectX12-Chinese

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
markdown-build.py 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
Link Clinton 提交于 2018-03-16 21:35 . Fix HtmlExport
import markdown2
def getMathCode(str):
isBegin = False
isDouble = False
mathCode = ""
result = []
for i in range(0, len(str)):
isCurrentEnd = False
if (str[i] is '$'):
if (isBegin is False):
isBegin = True
isDouble = False
else:
if (isDouble is False):
if (str[i-1] is '$'):
isDouble = True
else:
isBegin = False
isDouble = False
isCurrentEnd = True
else:
if (str[i-1] is '$'):
isBegin = False
isDouble = False
isCurrentEnd = True
if (isBegin is True or isCurrentEnd is True):
mathCode += str[i]
if (isCurrentEnd is True):
result.append(mathCode)
mathCode = ""
pass
return result
htmlHead = open("./head.html").read()
buildFile = open("./buildList.txt").readlines()
for item in buildFile:
fileName = item.rstrip('\n')
sourceFile = open(fileName + ".md", encoding = "utf-8").read()
mathCodes = getMathCode(sourceFile)
mathCodeCount = 0
result = htmlHead
html = markdown2.markdown_path(fileName + ".md",
extras=["fenced-code-blocks","code-friendly", "code-color", "tables"])
isBegin = False
isDouble = False
for i in range(0, len(html)):
isCurrentEnd = False
if (html[i] is '$'):
if (isBegin is False):
isBegin = True
isDouble = False
else:
if (isDouble is False):
if (html[i-1] is '$'):
isDouble = True
else:
isBegin = False
isDouble = False
isCurrentEnd = True
else:
if (html[i-1] is '$'):
isBegin = False
isDouble = False
isCurrentEnd = True
if (isBegin is False and isCurrentEnd is False):
result += html[i]
if (isCurrentEnd is True):
result += mathCodes[mathCodeCount]
mathCodeCount += 1
pass
output = open("./" + fileName + ".html", "w" , encoding= "utf-16")
output.write(result)
pass
indexHtml = htmlHead + markdown2.markdown_path("readme.md",
extras=["fenced-code-blocks","code-friendly", "code-color", "tables"])
output = open("./"+"index.html","w",encoding= "utf-16")
output.write(indexHtml)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lichsword/IGP-DirectX12-Chinese.git
git@gitee.com:lichsword/IGP-DirectX12-Chinese.git
lichsword
IGP-DirectX12-Chinese
IGP-DirectX12-Chinese
master

搜索帮助