|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 hoebec 于 2022-5-26 23:59 编辑
注意! 以下内容涉及 我的现实与网游被恋爱喜剧侵蚀了 台版1-8卷的各种原文
epub的机器转换实际是关于图片,排版,目录,注释,上标的一套解决方案(私有标准),基本上每种轮距都不太一致,所以最花时间的部分是预处理文本
脚本预设是使用"<chapter>"作为章节标志,可以修改为任意字符(单独一行)
注释是在行内直接输入,以"(注:" "(注:"之类特定文字提取
对于各种弹注方式,可以自己编写扩展
图片为直接输入文件名
可以修改参数方便直排横排
内置Duokan的样式,锁字体等
只支持输入Unicode格式的txt文件(utf16le),不支持Utf-8,论坛下载的txt文件必须先手动保存为Unicode格式
基本格式:
在txt同一文件夹内,以txt同名目录,或Images目录,或image目录作为图片文件夹,以fonts目录或font目录作为字体文件夹
在章节前,输入<chapter>作为单独一行
以图片文件夹内的图片文件名(包括后缀)作为单独一行,识别为图片行(大小写通用,jpg与jpeg通用)
运行方式:
双击运行vbs,拖放txt文件,ENTER,下一步输入作者名(脚本会尝试自动从txt文件读取),再下一步输入画师名(会尝试自动读取),ENTER,开始制作EPUB,等待1-2秒,脚本提示完成,并列出章节目录,及注释,上标,图片等统计结果
以下是实际的vbs制作脚本,必须以Unicode方式保存(保存为Unicode格式的txt,修改后缀名为vbs),大小约100k
- Set WshShell = CreateObject("Wscript.Shell")
- Set objFSO = CreateObject("scripting.filesystemobject")
- Set objAdodbStream = CreateObject("Adodb.Stream")
- scriptloadtempbat=objFSO.GetSpecialFolder(2)&"\"&"scriptloadtemp.bat"
- If Wscript.arguments.count=0 Then
- WshShell.run "cmd /c echo @echo off>"&scriptloadtempbat&"",0,True
- WshShell.run "cmd /c echo setlocal enabledelayedexpansion>>"&scriptloadtempbat&"",0,True
- WshShell.run "cmd /c echo :input>>"&scriptloadtempbat&"",0,True
- WshShell.run "cmd /c echo Set /p ""input=input txt:"">>"&scriptloadtempbat&"",0,True
- WshShell.run "cmd /c echo if not defined input goto input>>"&scriptloadtempbat&"",0,True
- WshShell.run "cmd /c echo start """" """&Wscript.ScriptFullName&""" !input!>>"&scriptloadtempbat&"",0,True
- WshShell.run("cmd /c "&scriptloadtempbat&"")
- Wscript.quit
- End If
- If Wscript.arguments.count=1 Then objFSO.DeleteFile(scriptloadtempbat)
- If Wscript.arguments.count=1 Then Input=Wscript.arguments(0)
- If not objFSO.FileExists(Input) Then Wscript.quit
- covername="封面"
- tocimgname="插圖"
- tocmakeinfo="製作信息"
- tocintroname="內容簡介"
- tocauthname="作者簡介"
- tocpagecolor="彩頁"
- toclistpage="目錄"
- tocimgpagename="插圖集"
- covername="封面"
- tocimgname="插图"
- tocmakeinfo="制作信息"
- tocintroname="内容简介"
- tocauthname="作者简介"
- tocpagecolor="彩页"
- toclistpage="目录"
- tocimgpagename="插图集"
- imagemissinginfo="找不到图片文件!"
- rubya="|"
- rubyb="《"
- rubyc="》"
- rubycount=0
- rubyerror=0
- footnotecount=0
- footnoteerror=0
- imagepage=1
- numbercenter=1
- symbolcenter=1
- lineheight="1.3"
- textindent="2em"
- margintop="1em"
- marginbottom="1em"
- marginp="0.5em"
- vrtl="vrtl"
- vrtl="hltr"
- rtl="rtl"
- rtl="ltr"
- author=EMPTY
- author2=EMPTY
- language="zh"
- publisher=""
- dcdate=""
- dcid="uid"
- chapterbreak="<chapter>"
- duokanbleed="leftright"
- duokancover="duokan-page-fitwindow"
- duokancover="duokan-page-fullscreen"
- duokanfontfixed=1
- emptylineskip=0
- footnotetype="newline"
- footnotetype="duokan"
- footnotecolor="#a0513c"
- footnotefontsize="0.8em"
- footnoteimagesize="0.9em"
- htmlfontbsn=EMPTY
- footnotebsn=EMPTY
- chaptercount=0
- fontcount=0
- tocimgline=1
- tocnum=0
- txtbackup=1
- inputfiledelete=0
- arrsymbol=Array("†","*","﹡","*","§","※","◆","◇","■","□","♣","♧","★","☆"," "," ","+","▪","▫","▲","△","▼","▽","●","○","◌","♡","♥","❤","■","○","×")
- arrintro=Array("简介","简 介","简 介","内容简介","书籍简介","簡介","簡 介","簡 介","內容簡介","書籍簡介","简介:","简 介:","简 介:","内容简介:","书籍简介:","簡介:","簡 介:","簡 介:","內容簡介:","書籍簡介:","简介︰","简 介︰","简 介︰","内容简介︰","书籍简介︰","簡介︰","簡 介︰","簡 介︰","內容簡介︰","書籍簡介︰","简介:","简 介:","简 介:","内容简介:","书籍简介:","簡介:","簡 介:","簡 介:","內容簡介:","書籍簡介:")
- arrauthor=Array("作者简介","作者簡介","作者简介:","作者簡介:","作者简介︰","作者簡介︰","作者简介:","作者簡介:")
- arrinfo=Array("制作信息","製作信息","制作信息:","製作信息:","制作信息︰","製作信息︰","制作信息:","製作信息:")
- arraut=Array("作者:","作者︰","作者:","作 者:","作 者︰","作 者:","作者 :","作者 ︰","作者 :","作 者 :","作 者 ︰","作 者 :")
- arrgak=Array("插画:","插画︰","插画:","插畫:","插畫︰","插畫:","绘者:","绘者︰","绘者:","繪者:","繪者︰","繪者:","画师:","画师︰","画师:","畫師:","畫師︰","畫師:","插 画:","插 画︰","插 画:","插 畫:","插 畫︰","插 畫:","绘 者:","绘 者︰","绘 者:","繪 者:","繪 者︰","繪 者:","画 师:","画 师︰","画 师:","畫 師:","畫 師︰","畫 師:")
- arrfootnote=Array("注","註","译注","编注","录注","校注","譯注","編注","錄注","译註","编註","录註","校註","譯註","編註","錄註","译者注","翻译注","编者注","编辑注","录入注","校对注","譯者注","翻譯注","編者注","編輯注","錄入注","校對注","译者註","翻译註","编者註","编辑註","录入註","校对註","譯者註","翻譯註","編者註","編輯註","錄入註","校對註")
- arrlabel=Array("<a>","</a>","<article>","</article>","<aside>","</aside>","<audio>","</audio>","<b>","</b>","<bdi>","</bdi>","<bdo>","<bdo dir=""ltr"">","<bdodir=""rtl"">","</bdo>","<big>","</big>","<blockquote>","</blockquote>","<body>","</body>","<br>","<br/>","<br/>","<button>","</button>","<caption>","</caption>","<center>","</center>","<cite>","</cite>","<code>","</code>","<col>","</col>","<colgroup>","</colgroup>","<command>","</command>","<datalist>","</datalist>","<dd>","</dd>","<del>","</del>","<div>","</div>","<dfn>","</dfn>","<dl>","</dl>","<dt>","</dt>","<em>","</em>","<fieldset>","</fieldset>","<figcaption>","</figcaption>","<figure>","</figure>","<footer>","</footer>","<form>","</form>","<frame>","</frame>","<h1>","</h1>","<h2>","</h2>","<h3>","</h3>","<h4>","</h4>","<h5>","</h5>","<h6>","</h6>","<head>","</head>","<hr>","<hr/>","<hr/>","<html>","</html>","<i>","</i>","<iframe>","</iframe>","<img>","</img>","<ins>","</ins>","<kbd>","</kbd>","<legend>","</legend>","<li>","</li>","<mark>","</mark>","<nav>","</nav>","<noframes>","</noframes>","<noscript>","</noscript>","<object>","</object>","<ol>","</ol>","<optgroup>","</optgroup>","<option>","</option>","<p>","</p>","<pre>","</pre>","<q>","</q>","<rp>","</rp>","<rt>","</rt>","<ruby>","</ruby>","<s>","</s>","<samp>","</samp>","<script>","</script>","<section>","</section>","<select>","</select>","<small>","</small>","<span>","</span>","<strike>","</strike>","<strong>","</strong>","<style>","</style>","<sub>","</sub>","<sup>","</sup>","<table>","</table>","<td>","</td>","<time>","</time>","<title>","</title>","<tr>","</tr>","<tt>","</tt>","<u>","</u>","<ul>","</ul>","<var>","</var>","<video>","</video>","<skip>","</skip>","<split>","</split>","<chapter>","<content>","</content>")
- FilterAuthor
- author = Inputbox("author:",,author)
- If IsEmpty(author) Then Wscript.quit
- If author<>EMPTY Then author2 = Inputbox("author2:",,author2)
- If IsEmpty(author2) Then Wscript.quit
- If dcdate<>EMPTY Then pubdate=dcdate&"T16:00:00+00:00"
- If uid=EMPTY Then uid=LCase(Mid(CreateObject("Scriptlet.TypeLib").GUID,2,36))
- If rtl="rtl" Then vrtl="vrtl"
- epubfiletitle=objFSO.GetBaseName(Input)
- tempmakingfolder=objFSO.GetSpecialFolder(2)&"\"&"tempmakingfolder"
- metainffolder=tempmakingfolder&"\"&"META-INF"
- oebpsfolder=tempmakingfolder&"\"&"OEBPS"
- textfolder=oebpsfolder&"\"&"Text"
- imagesfolder=oebpsfolder&"\"&"Images"
- stylesfolder=oebpsfolder&"\"&"Styles"
- fontsfolder=oebpsfolder&"\"&"Fonts"
- imgfolder=objFSO.GetParentFolderName(Input)&"\"&epubfiletitle
- fntfolder=objFSO.GetParentFolderName(Input)&"\"&"fonts"
- If not objFSO.FolderExists(imgfolder) Then imgfolder=objFSO.GetParentFolderName(Input)&"\"&"Images"
- If not objFSO.FolderExists(imgfolder) Then imgfolder=objFSO.GetParentFolderName(Input)&"\"&"image"
- If not objFSO.FolderExists(fntfolder) Then fntfolder=objFSO.GetParentFolderName(Input)&"\"&"font"
- If objFSO.FolderExists(tempmakingfolder) Then objFSO.DeleteFolder(tempmakingfolder)
- If not objFSO.FolderExists(tempmakingfolder) Then objFSO.createFolder(tempmakingfolder)
- objFSO.createFolder(metainffolder)
- objFSO.createFolder(oebpsfolder)
- objFSO.createFolder(textfolder)
- objFSO.createFolder(imagesfolder)
- objFSO.createFolder(stylesfolder)
- If txtbackup=1 Then
- objFSO.createFolder(tempmakingfolder&"\"&"OEBPS"&"\"&"Backup")
- objFSO.GetFile(Input).Copy(tempmakingfolder&"\"&"OEBPS"&"\"&"Backup"&"\"&"backup.txt")
- End If
- If objFSO.FolderExists(imgfolder) Then
- For Each i in objFSO.GetFolder(imgfolder).files
- ext=LCase(objFSO.GetExtensionName(i))
- If ext="jpg" or ext="png" or ext="jpeg" or ext="webp" Then
- imagecopycount=imagecopycount+1
- i.attributes=0
- objFSO.GetFile(i).Copy(imagesfolder&"\"&i.name)
- End If
- Next
- If imagecopycount=EMPTY Then
- Wscript.echo imagemissinginfo
- Wscript.quit
- End If
- Else
- Wscript.echo imagemissinginfo
- Wscript.quit
- End If
- If objFSO.FolderExists(fntfolder) Then
- For Each i in objFSO.GetFolder(fntfolder).files
- ext=LCase(objFSO.GetExtensionName(i))
- bsn=LCase(objFSO.GetBaseName(i))
- If ext="ttf" or ext="otf" Then
- If bsn="footnote" Then footnotebsn=objFSO.GetBaseName(i)
- If bsn<>"footnote" and htmlfontbsn=EMPTY Then htmlfontbsn=objFSO.GetBaseName(i)
- If not objFSO.FolderExists(fontsfolder) Then objFSO.createFolder(fontsfolder)
- i.attributes=0
- objFSO.GetFile(i).Copy(fontsfolder&"\"&i.name)
- fontcount=fontcount+1
- End If
- Next
- If footnotebsn=EMPTY and htmlfontbsn<>EMPTY Then footnotebsn=htmlfontbsn
- If htmlfontbsn<>EMPTY and duokanfontfixed=1 Then dcid="duokan-book-id"
- End If
- If not objFSO.FileExists(imagesfolder&"\"&"footnote.png") Then footnotetype="newline"
- For Each i in objFSO.GetFolder(imgfolder).files
- imagecount=imagecount+1
- coverext=LCase(objFSO.GetExtensionName(i))
- If imagecount=1 Then coverimgfn=i.name
- If LCase(objFSO.GetBaseName(i))="cover" Then coverimgfn=i.name
- Next
- covermtp=LCase(coverext)
- If covermtp="jpg" Then covermtp="jpeg"
- Set mimetype = objFSO.OpenTextFile(tempmakingfolder&"\"&"mimetype",2,1,0)
- mimetype.Write "application/epub+zip"
- mimetype.close
- Set containerxml = objFSO.OpenTextFile(metainffolder&"\"&"container.xml",2,1,0)
- containerxml.Write "<?xml version=""1.0"" encoding=""UTF-8""?>"&vblf&"<container version=""1.0"" xmlns=""urn:oasis:names:tc:opendocument:xmlns:container"">"&vblf&" <rootfiles>"&vblf&"<rootfile full-path=""OEBPS/content.opf"" media-type=""application/oebps-package+xml""/> </rootfiles>"&vblf&"</container>"&vblf&""
- containerxml.close
- Set contentopf = objFSO.OpenTextFile(oebpsfolder&"\"&"content.opf",2,1,-1)
- contentopf.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- contentopf.WriteLine "<package xmlns=""http://www.idpf.org/2007/opf"" version=""2.0"" unique-identifier="""&dcid&""">"
- contentopf.WriteLine "<metadata xmlns:dc=""http://purl.org/dc/elements/1.1/"" xmlns:opf=""http://www.idpf.org/2007/opf"">"
- contentopf.WriteLine "<meta name=""cover"" content=""cover-image""/>"
- contentopf.WriteLine "<meta name=""output encoding"" content=""utf-8""/>"
- contentopf.WriteLine "<dc:title>"&epubfiletitle&"</dc:title>"
- If author<>EMPTY Then contentopf.WriteLine "<dc:creator id=""creator01"">"&author&"</dc:creator>"
- If author2<>EMPTY Then contentopf.WriteLine "<dc:creator id=""creator02"">"&author2&"</dc:creator>"
- If language<>EMPTY Then contentopf.WriteLine "<dc:language>"&language&"</dc:language>"
- If publisher<>EMPTY Then contentopf.WriteLine "<dc:publisher>"&publisher&"</dc:publisher>"
- If pubdate<>EMPTY Then contentopf.WriteLine "<dc:date>"&pubdate&"</dc:date>"
- If uid<>EMPTY Then contentopf.WriteLine "<dc:identifier id="""&dcid&""">"&uid&"</dc:identifier>"
- contentopf.WriteLine "</metadata>"
- contentopf.WriteBlankLines(1)
- contentopf.WriteLine "<manifest>"
- contentopf.WriteLine space(4)&"<item id=""ncx"" media-type=""application/x-dtbncx+xml"" href=""toc.ncx""/>"
- contentopf.WriteLine space(4)&"<item id=""cover-image"" media-type=""image/"&covermtp&""" href=""Images/"&coverimgfn&"""/>"
- contentopf.WriteLine space(4)&"<item id=""style0001.css"" media-type=""text/css"" href=""Styles/style0001.css""/>"
- Set stylecss = objFSO.OpenTextFile(stylesfolder&"\"&"style0001.css",2,1,-1)
- stylecss.WriteLine "@charSet ""UTF-8"";"
- stylecss.WriteBlankLines(1)
- If fontcount>0 Then
- For Each i in objFSO.GetFolder(fontsfolder).files
- stylecss.WriteLine "@font-face {"
- stylecss.WriteLine " font-family: """&objFSO.GetBaseName(i)&""";"
- stylecss.WriteLine " src: url(../Fonts/"&i.name&");"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- Next
- End If
- stylecss.WriteLine "* { margin: 0; padding: 0; }"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine "img {"
- stylecss.WriteLine " width: 100%;"
- stylecss.WriteLine " height: auto;"
- stylecss.WriteLine " margin: 0;"
- stylecss.WriteLine " padding: 0;"
- stylecss.WriteLine " border: none;"
- stylecss.WriteLine " vertical-align: baseline;"
- stylecss.WriteLine " background: transparent;"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine "html,"
- stylecss.WriteLine ".hltr { writing-mode: horizontal-tb; }"
- stylecss.WriteLine ".vrtl { writing-mode: vertical-rl; }"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine "body {"
- stylecss.WriteLine " font-size: 100%;"
- If htmlfontbsn<>EMPTY Then
- stylecss.WriteLine " font-family: "&htmlfontbsn&";"
- End If
- stylecss.WriteLine " vertical-align: baseline;"
- stylecss.WriteLine " line-height: "&lineheight&";"
- stylecss.WriteLine " text-indent: "&textindent&";"
- stylecss.WriteLine " background: transparent;"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine " word-spacing: normal;"
- stylecss.WriteLine " letter-spacing: normal;"
- stylecss.WriteLine " white-space: normal;"
- stylecss.WriteLine " word-wrap: break-word;"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine " line-break: normal;"
- stylecss.WriteLine " -epub-line-break: normal;"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine " word-break: normal;"
- stylecss.WriteLine " -epub-word-break: normal;"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine " hyphens: auto;"
- stylecss.WriteLine " -epub-hyphens: auto;"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine " font-weight: normal;"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine " margin-top: "&margintop&";"
- stylecss.WriteLine " margin-bottom: "&marginbottom&";"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine "p { margin-top: "&marginp&"; }"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine "a { text-decoration: none; }"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine ".font-1em30 { font-size: 1.3em; }"
- stylecss.WriteLine ".align-center { text-align: center; text-indent: 0; }"
- stylecss.WriteLine ".align-left { text-align: left; text-indent: 0; }"
- stylecss.WriteLine ".align-right { text-align: right; text-indent: 0; }"
- stylecss.WriteLine ".duokan-bleed { duokan-bleed: "&duokanbleed&"; }"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine ".footnote-img {"
- stylecss.WriteLine " height: "&footnoteimagesize&";"
- stylecss.WriteLine " width: auto;"
- stylecss.WriteLine " margin-left: 0;"
- stylecss.WriteLine " margin-right: 0;"
- stylecss.WriteLine " margin-top: 0;"
- stylecss.WriteLine " margin-bottom: 0;"
- stylecss.WriteLine " padding: 0;"
- stylecss.WriteLine " text-align: left;"
- stylecss.WriteLine " vertical-align: top;"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine ".footnote-text {"
- stylecss.WriteLine " font-size: "&footnotefontsize&";"
- If footnotebsn<>EMPTY Then
- stylecss.WriteLine " font-family: "&footnotebsn&";"
- End If
- If footnotecolor<>EMPTY Then
- stylecss.WriteLine " color: "&footnotecolor&";"
- End If
- stylecss.WriteLine " margin-top: 0;"
- stylecss.WriteLine " margin-bottom: 0;"
- stylecss.WriteLine " padding: 0;"
- stylecss.WriteLine " text-indent: 0;"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine ".footnote-size {"
- stylecss.WriteLine " font-size: "&footnotefontsize&";"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine ".footnote-color {"
- stylecss.WriteLine " color: "&footnotecolor&";"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.WriteLine ".border-dashed {"
- stylecss.WriteLine " border: 1px dashed "&footnotecolor&";"
- stylecss.WriteLine " border-radius: 5px;"
- stylecss.WriteLine " padding: 1px 3px;"
- stylecss.WriteLine "}"
- stylecss.WriteBlankLines(1)
- stylecss.close
- Set tocncx = objFSO.OpenTextFile(oebpsfolder&"\"&"toc.ncx",2,1,-1)
- tocncx.WriteLine "<?xml version='1.0' encoding='utf-8'?>"
- tocncx.WriteLine "<ncx xmlns=""http://www.daisy.org/z3986/2005/ncx/"" version=""2005-1"" xml:lang="""&language&""">"
- tocncx.WriteLine "<head>"
- tocncx.WriteLine "<meta content="""&uid&""" name=""dtb:uid""/>"
- tocncx.WriteLine "<meta content=""2"" name=""dtb:depth""/>"
- tocncx.WriteLine "<meta content=""0"" name=""dtb:totalPageCount""/>"
- tocncx.WriteLine "<meta content=""0"" name=""dtb:maxPageNumber""/>"
- tocncx.WriteLine "</head>"
- tocncx.WriteLine "<docTitle>"
- tocncx.WriteLine space(2)&"<text>"&epubfiletitle&"</text>"
- tocncx.WriteLine "</docTitle>"
- tocncx.WriteLine "<navMap>"
- Set ptoc = objFSO.OpenTextFile(textfolder&"\"&"p-toc.xhtml",2,1,-1)
- ptoc.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- ptoc.WriteLine "<!DOCTYPE html>"
- ptoc.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- ptoc.WriteLine "<head>"
- ptoc.WriteLine "<meta charset=""UTF-8""/>"
- ptoc.WriteLine "<title>"&epubfiletitle&"</title>"
- ptoc.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- ptoc.WriteLine "</head>"
- ptoc.WriteLine "<body>"
- ptoc.WriteLine "<p class=""font-1em30 align-center""><a href=""cover.xhtml"">"&epubfiletitle&"</a></p>"
- ptoc.WriteLine "<br />"
- Dim ImgUsedArray
- ReDim ImgUsedArray(0)
- imgur=0
- ImgUsedArray(0)=coverimgfn
- Dim ImgMissingArray
- ReDim ImgMissingArray(0)
- imgnr=0
- ImgMissingArray(0)=coverimgfn
- epubcontentpreview=objFSO.GetSpecialFolder(2)&"\"&"epubcontentpreview.txt"
- Set pre = objFSO.OpenTextFile(epubcontentpreview,2,1,-1)
- Set fnp = objFSO.OpenTextFile(Input,1,0,-1)
- Do until fnp.AtEndOfStream
- htline=fnp.ReadLine
- htline=Trim(htline)
- If htline=chapterbreak Then
- chaptercount=chaptercount+1
- If chaptercount>1 Then tocncx.WriteLine space(2)&"</navPoint>"
- pch.WriteLine "</body></html>"
- pch.close
- htline=EMPTY
- imgbw=EMPTY
- imgbwch=EMPTY
- splitbw=EMPTY
- emptylinecount=0
- linecountch=0
- htlpn="p-ch"&Right("000"&chaptercount,3)&".xhtml"
- htlpath=textfolder&"\"&htlpn
- Set pch = objFSO.OpenTextFile(htlpath,2,1,-1)
- End If
- If chaptercount>0 Then
- linecountch=linecountch+1
- If linecountch=1 Then
- Do while htline=EMPTY
- htline=fnp.ReadLine
- htline=Trim(htline)
- Loop
- imghtr4=LCase(Right(htline,4))
- imghtr5=LCase(Right(htline,5))
- If imghtr4=".jpg" or imghtr4=".png" or imghtr5=".jpeg" or imghtr5=".webp" Then
- imgline=1
- hta=htline
- Do
- htline=fnp.ReadLine
- htline=Trim(htline)
- Loop until htline<>EMPTY
- End If
- htmltitle=htline
- htmltitle=ReplaceEsc(htmltitle)
- htmlchapter=ReplaceRuby(htmltitle)
- htmltitle=FilterRubyText(htmltitle)
- htmltitle=FilterHtmlLabel(htmltitle)
- htmltitle=FilterRubyText(htmltitle)
- htmltitle=FilterFootnote(htmltitle)
- pch.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- pch.WriteLine "<!DOCTYPE html>"
- pch.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- pch.WriteLine "<head>"
- pch.WriteLine "<meta charset=""UTF-8""/>"
- pch.WriteLine "<title>"&htmltitle&"</title>"
- pch.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- pch.WriteLine "</head>"
- pch.WriteLine "<body>"
- If imgline=1 Then
- hta=GetJpegName(hta)
- imgtextpath=imgfolder&"\"&hta
- If objFSO.FileExists(imgtextpath) Then
- imgtextpathfn=objFSO.GetFile(imgtextpath).name
- imgur=imgur+1
- ReDim Preserve ImgUsedArray(imgur)
- ImgUsedArray(imgur)=imgtextpathfn
- Else
- imgtextpathfn=hta
- imgnr=imgnr+1
- ReDim Preserve ImgMissingArray(imgnr)
- ImgMissingArray(imgnr)=hta
- End If
- pch.WriteLine "<div class=""align-center duokan-image-single duokan-bleed""><img src=""../Images/"&imgtextpathfn&""" alt=""""/></div>"
- End If
- If Left(htmlchapter,6)<>"<skip>" Then
- chaptertitle="<p class=""font-1em30 align-center"">"&htmlchapter&"</p>"
- If rtl="rtl" Then
- chaptertitle="<p class=""font-1em30"">"&htmlchapter&"</p>"
- End If
- ReplaceFootnote chaptertitle,honntai,bunshin
- pch.WriteLine honntai
- If bunshin<>EMPTY Then
- pch.WriteLine bunshin
- End If
- honntai=EMPTY
- bunshin=EMPTY
- End If
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&htmltitle&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/"&htlpn&"""/>"
- ptoc.WriteLine "<p class=""align-center""><a href="""&htlpn&""">"&htmltitle&"</a></p>"
- pre.WriteLine htmltitle
- End If
- If linecountch>1 Then
- hta=htline
- If hta="<split>" Then hta=EMPTY
- If hta=EMPTY and imgbwch<>1 and emptylineskip<>1 and splitbw<>1 Then
- emptylinecount=emptylinecount+1
- End If
- If hta<>EMPTY Then
- imghtr4=LCase(Right(hta,4))
- imghtr5=LCase(Right(hta,5))
- If imghtr4=".jpg" or imghtr4=".png" or imghtr5=".jpeg" or imghtr5=".webp" Then
- imgline=1
- imgbwch=1
- End If
- If imgline=1 Then
- hta=GetJpegName(hta)
- imgtextpath=imgfolder&"\"&hta
- If objFSO.FileExists(imgtextpath) Then
- imgtextpathfn=objFSO.GetFile(imgtextpath).name
- imgur=imgur+1
- ReDim Preserve ImgUsedArray(imgur)
- ImgUsedArray(imgur)=imgtextpathfn
- Else
- imgtextpathfn=hta
- imgnr=imgnr+1
- ReDim Preserve ImgMissingArray(imgnr)
- ImgMissingArray(imgnr)=hta
- End If
- pch.WriteLine "<div class=""align-center duokan-image-single duokan-bleed""><a name="""&imgtextpathfn&"""><img src=""../Images/"&imgtextpathfn&""" alt=""""/></a></div>"
- If tocimgline=1 Then
- tocimgcount=tocimgcount+1
- tocnum=tocnum+1
- tocncx.WriteLine space(6)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(6)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&tocimgname&""&tocimgcount&"</text>"
- tocncx.WriteLine space(6)&"</navLabel>"
- tocncx.WriteLine space(6)&"<content src=""Text/"&htlpn&"#"&imgtextpathfn&"""/>"
- tocncx.WriteLine space(6)&"</navPoint>"
- pre.WriteLine " "&tocimgname&tocimgcount
- End If
- End If
- If imgline<>1 Then
- If imgbwch=EMPTY Then
- If emptylinecount<>0 Then
- For emc=1 To emptylinecount
- pch.WriteLine "<br />"
- Next
- emptylinecount=0
- End If
- End If
- hta=ReplaceEsc(hta)
- hta=ReplaceRuby(hta)
- If CheckTagpSkip(hta)=EMPTY Then
- If CheckSymbol(hta)=1 and symbolcenter=1 or IsNumeric(hta) and numbercenter=1 Then
- ftn="<p class=""align-center"">"&hta&"</p>"
- Else
- ftn="<p>"&hta&"</p>"
- End If
- Else
- ftn=hta
- End If
- ReplaceFootnote ftn,honntai,bunshin
- pch.WriteLine honntai
- If bunshin<>EMPTY Then
- pch.WriteLine bunshin
- End If
- honntai=EMPTY
- bunshin=EMPTY
- End If
- End If
- End If
- End If
- If chaptercount=0 Then
- linecountp=linecountp+1
- If linecountp=1 Then
- htlp=htlp+1
- htmltitle=htline
- htmltitle=ReplaceEsc(htmltitle)
- htmlchapter=ReplaceRuby(htmltitle)
- htmltitle=FilterRubyText(htmltitle)
- htmltitle=FilterHtmlLabel(htmltitle)
- htmltitle=FilterRubyText(htmltitle)
- htmltitle=FilterFootnote(htmltitle)
- htlpn="p-"&Right("000"&htlp,3)&".xhtml"
- htlpath=textfolder&"\"&htlpn
- Set pch = objFSO.OpenTextFile(htlpath,2,1,-1)
- pch.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- pch.WriteLine "<!DOCTYPE html>"
- pch.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- pch.WriteLine "<head>"
- pch.WriteLine "<meta charset=""UTF-8""/>"
- pch.WriteLine "<title>"&htmltitle&"</title>"
- pch.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- pch.WriteLine "</head>"
- pch.WriteLine "<body>"
- If Left(htmlchapter,6)<>"<skip>" Then
- chaptertitle="<p class=""font-1em30 align-center"">"&htmlchapter&"</p>"
- If rtl="rtl" Then
- chaptertitle="<p class=""font-1em30"">"&htmlchapter&"</p>"
- End If
- ReplaceFootnote chaptertitle,honntai,bunshin
- pch.WriteLine honntai
- If bunshin<>EMPTY Then
- pch.WriteLine bunshin
- End If
- honntai=EMPTY
- bunshin=EMPTY
- End If
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&covername&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/cover.xhtml""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- pre.WriteLine covername
- End If
- If linecountp>1 Then
- hta=htline
- If hta="<split>" Then
- hta=EMPTY
- splitbw=1
- emptylinecount=0
- End If
- If imgbw=1 Then emptylinecount=0
- If hta=EMPTY and imgbw<>1 and emptylineskip<>1 and splitbw<>1 Then
- emptylinecount=emptylinecount+1
- End If
- If hta<>EMPTY Then
- imghtr4=LCase(Right(hta,4))
- imghtr5=LCase(Right(hta,5))
- If imghtr4=".jpg" or imghtr4=".png" or imghtr5=".jpeg" or imghtr5=".webp" Then
- imgline=1
- End If
- If imgline=1 Then
- hta=GetJpegName(hta)
- imgtextpath=imgfolder&"\"&hta
- If objFSO.FileExists(imgtextpath) Then
- imgtextpathfn=objFSO.GetFile(imgtextpath).name
- imgur=imgur+1
- ReDim Preserve ImgUsedArray(imgur)
- ImgUsedArray(imgur)=imgtextpathfn
- Else
- imgtextpathfn=hta
- imgnr=imgnr+1
- ReDim Preserve ImgMissingArray(imgnr)
- ImgMissingArray(imgnr)=hta
- End If
- pch.WriteLine "</body></html>"
- pch.close
- htlp=htlp+1
- htlpn="p-"&Right("000"&htlp,3)&".xhtml"
- htlpath=textfolder&"\"&htlpn
- Set pch = objFSO.OpenTextFile(htlpath,2,1,-1)
- colorpage=colorpage+1
- If colorpage=1 Then
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&tocpagecolor&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/"&htlpn&"""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href="""&htlpn&""">"&tocpagecolor&"</a></p>"
- pre.WriteLine tocpagecolor
- End If
- pch.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- pch.WriteLine "<!DOCTYPE html>"
- pch.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- pch.WriteLine "<head>"
- pch.WriteLine "<meta charset=""UTF-8""/>"
- pch.WriteLine "<title>"&tocpagecolor&"</title>"
- pch.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- pch.WriteLine "</head>"
- pch.WriteLine "<body>"
- pch.WriteLine "<div class=""align-center duokan-image-single duokan-bleed""><a name="""&imgtextpathfn&"""><img src=""../Images/"&htline&""" alt=""""/></a></div>"
- imgbw=1
- End If
- If imgline<>1 Then
- If CheckIntro(hta)=1 Then tocintro=1
- If CheckInfo(hta)=1 Then tocinfo=1
- If CheckAuthor(hta)=1 Then tocauthor=1
- If Left(hta,9)="<content>" and Right(hta,10)="</content>" Then tocpage=1
- hta=ReplaceEsc(hta)
- hta=ReplaceRuby(hta)
- If imgbw<>1 and splitbw<>1 Then
- If emptylinecount<>0 Then
- For emc=1 To emptylinecount
- pch.WriteLine "<br />"
- Next
- emptylinecount=0
- End If
- If CheckTagpSkip(hta)=EMPTY Then
- If CheckSymbol(hta)=1 and symbolcenter=1 or IsNumeric(hta) and numbercenter=1 Then
- ftn="<p class=""align-center"">"&hta&"</p>"
- Else
- ftn="<p>"&hta&"</p>"
- End If
- Else
- ftn=hta
- End If
- ReplaceFootnote ftn,honntai,bunshin
- pch.WriteLine honntai
- If bunshin<>EMPTY Then
- pch.WriteLine bunshin
- End If
- honntai=EMPTY
- bunshin=EMPTY
- End If
- If imgbw=1 or splitbw=1 Then
- imgbw=EMPTY
- splitbw=EMPTY
- pch.WriteLine "</body></html>"
- pch.close
- htlp=htlp+1
- htlpn="p-"&Right("000"&htlp,3)&".xhtml"
- htlpath=textfolder&"\"&htlpn
- Set pch = objFSO.OpenTextFile(htlpath,2,1,-1)
- pch.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- pch.WriteLine "<!DOCTYPE html>"
- pch.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- pch.WriteLine "<head>"
- pch.WriteLine "<meta charset=""UTF-8""/>"
- pch.WriteLine "<title>"&htmltitle&"</title>"
- pch.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- pch.WriteLine "</head>"
- pch.WriteLine "<body>"
- If CheckTagpSkip(hta)<>1 Then
- If CheckSymbol(hta)=1 and symbolcenter=1 or IsNumeric(hta) and numbercenter=1 Then
- ftn="<p class=""align-center"">"&hta&"</p>"
- Else
- ftn="<p>"&hta&"</p>"
- End If
- Else
- ftn=hta
- End If
- ReplaceFootnote ftn,honntai,bunshin
- pch.WriteLine honntai
- If bunshin<>EMPTY Then
- pch.WriteLine bunshin
- End If
- honntai=EMPTY
- bunshin=EMPTY
- End If
- If tocintro=1 and tocintrowr=EMPTY Then
- tocintrowr=1
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&tocintroname&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/"&htlpn&"""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href="""&htlpn&""">"&tocintroname&"</a></p>"
- pre.WriteLine tocintroname
- End If
- If tocinfo=1 and tocinfowr=EMPTY Then
- tocinfowr=1
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&tocmakeinfo&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/"&htlpn&"""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href="""&htlpn&""">"&tocmakeinfo&"</a></p>"
- pre.WriteLine tocmakeinfo
- End If
- If tocauthor=1 and tocauthwr=EMPTY Then
- tocauthwr=1
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&tocauthname&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/"&htlpn&"""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href="""&htlpn&""">"&tocauthname&"</a></p>"
- pre.WriteLine tocauthname
- End If
- If tocpage=1 and tocpagewr=EMPTY Then
- tocpagewr=1
- tocnum=tocnum+1
- contenthtmlfile=htlpn
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&toclistpage&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/"&htlpn&"""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href="""&htlpn&""">"&toclistpage&"</a></p>"
- pre.WriteLine toclistpage
- End If
- End If
- End If
- End If
- End If
- imgline=EMPTY
- Loop
- pch.WriteLine "</body></html>"
- pch.close
- fnp.close
- tocncx.WriteLine space(2)&"</navPoint>"
- If contenthtmlfile=EMPTY Then
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&toclistpage&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/p-toc.xhtml""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href=""p-toc.xhtml"">"&toclistpage&"</a></p>"
- pre.WriteLine toclistpage
- End If
- If imagepage=1 Then
- tocnum=tocnum+1
- tocncx.WriteLine space(2)&"<navPoint id=""np_"&tocnum&""" playOrder="""&tocnum&""">"
- tocncx.WriteLine space(4)&"<navLabel>"
- tocncx.WriteLine space(6)&"<text>"&tocimgpagename&"</text>"
- tocncx.WriteLine space(4)&"</navLabel>"
- tocncx.WriteLine space(4)&"<content src=""Text/t-img.xhtml""/>"
- tocncx.WriteLine space(2)&"</navPoint>"
- ptoc.WriteLine "<p class=""align-center""><a href=""t-img.xhtml"">"&tocimgpagename&"</a></p>"
- pre.WriteLine tocimgpagename
- End If
- tocncx.WriteLine "</navMap>"
- tocncx.WriteLine "</ncx>"
- tocncx.close
- ptoc.WriteLine "</body></html>"
- ptoc.close
- If contenthtmlfile<>EMPTY Then
- objFSO.DeleteFile(textfolder&"\"&contenthtmlfile)
- objFSO.GetFile(textfolder&"\"&"p-toc.xhtml").name=contenthtmlfile
- End If
- pre.WriteBlankLines(1)
- pre.WriteLine "Image Not Used:"
- imgurc=0
- For Each ir in objFSO.GetFolder(imagesfolder).files
- For iu=0 To UBound(ImgUsedArray)
- If LCase(ir.name)=LCase(ImgUsedArray(iu)) Then
- imu=1
- Exit For
- Else
- imu=EMPTY
- End If
- Next
- If imu=EMPTY Then
- pre.WriteLine ir.name
- imgurc=imgurc+1
- End If
- Next
- If imgurc=0 Then pre.WriteLine "none"
- pre.WriteBlankLines(1)
- pre.WriteLine "Image Not Exists:"
- If UBound(ImgMissingArray)=0 Then
- pre.WriteLine "none"
- Else
- For i=1 To UBound(ImgMissingArray)
- pre.WriteLine ImgMissingArray(i)
- Next
- End If
- pre.WriteBlankLines(1)
- pre.WriteLine "Ruby-Count: "&rubycount
- pre.WriteLine "Ruby-Error: "&rubyerror
- pre.WriteLine "Footnote-Count: "&footnotecount
- pre.WriteLine "Footnote-Error: "&footnoteerror
- pre.close
- Set coverhtml = objFSO.OpenTextFile(textfolder&"\"&"cover.xhtml",2,1,-1)
- coverhtml.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- coverhtml.WriteLine "<!DOCTYPE html>"
- coverhtml.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- coverhtml.WriteLine "<head>"
- coverhtml.WriteLine "<meta charset=""UTF-8""/>"
- coverhtml.WriteLine "<title>封面</title>"
- coverhtml.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- coverhtml.WriteLine "</head>"
- coverhtml.WriteLine "<body>"
- coverhtml.WriteLine "<p class=""align-center""><img src=""../Images/"&coverimgfn&""" alt=""""/></p>"
- coverhtml.WriteLine "</body>"
- coverhtml.WriteLine "</html>"
- coverhtml.close
- If imagepage=1 Then
- Set timg = objFSO.OpenTextFile(textfolder&"\"&"t-img.xhtml",2,1,-1)
- timg.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
- timg.WriteLine "<!DOCTYPE html>"
- timg.WriteLine "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:epub=""http://www.idpf.org/2007/ops"" xml:lang="""&language&""" class="""&vrtl&""">"
- timg.WriteLine "<head>"
- timg.WriteLine "<meta charset=""UTF-8""/>"
- timg.WriteLine "<title>"&tocimgpagename&"</title>"
- timg.WriteLine "<link rel=""stylesheet"" type=""text/css"" href=""../Styles/style0001.css""/>"
- timg.WriteLine "</head>"
- timg.WriteLine "<body>"
- For Each i in objFSO.GetFolder(imagesfolder).files
- timg.WriteLine "<div class=""align-center duokan-image-single duokan-bleed""><img src=""../Images/"&i.name&""" alt=""""/></div>"
- Next
- timg.WriteLine "</body>"
- timg.WriteLine "</html>"
- timg.close
- End If
- For Each i in objFSO.GetFolder(imagesfolder).files
- mtp=LCase(objFSO.GetExtensionName(i))
- If mtp="jpg" Then mtp="jpeg"
- contentopf.WriteLine space(4)&"<item id="""&i.name&""" media-type=""image/"&mtp&""" href=""Images/"&i.name&"""/>"
- Next
- If fontcount>0 Then
- For Each i in objFSO.GetFolder(fontsfolder).files
- mtp=LCase(objFSO.GetExtensionName(i))
- contentopf.WriteLine space(4)&"<item id="""&i.name&""" media-type=""application/x-font-"&mtp&""" href=""Fonts/"&i.name&"""/>"
- Next
- End If
- For Each i in objFSO.GetFolder(textfolder).files
- contentopf.WriteLine space(4)&"<item id="""&i.name&""" media-type=""application/xhtml+xml"" href=""Text/"&i.name&"""/>"
- Next
- contentopf.WriteLine "</manifest>"
- contentopf.WriteBlankLines(1)
- contentopf.WriteLine "<spine page-progression-direction="""&rtl&""" toc=""ncx"">"
- For Each i in objFSO.GetFolder(textfolder).files
- spinecount=spinecount+1
- If spinecount=1 Then
- contentopf.WriteLine space(4)&"<itemref idref="""&i.name&""" linear=""yes"" properties="""&duokancover&"""/>"
- Else
- contentopf.WriteLine space(4)&"<itemref idref="""&i.name&""" linear=""yes""/>"
- End If
- Next
- contentopf.WriteLine "</spine>"
- contentopf.WriteBlankLines(1)
- contentopf.WriteLine "<guide>"
- contentopf.WriteLine "<reference type=""cover"" title=""Cover"" href=""cover.xhtml""/>"
- contentopf.WriteLine "</guide>"
- contentopf.WriteLine "</package>"
- contentopf.close
- Utf8Convert stylesfolder&"\"&"style0001.css"
- Utf8Convert oebpsfolder&"\"&"content.opf"
- Utf8Convert oebpsfolder&"\"&"toc.ncx"
- For Each i in objFSO.GetFolder(textfolder).files
- Utf8Convert i.path
- Next
- Output=objFSO.GetParentFolderName(Input)&"\"&epubfiletitle&".zip"
- OutputEpub=objFSO.GetParentFolderName(Input)&"\"&epubfiletitle&".epub"
- If objFSO.FileExists(Output) Then
- objFSO.GetFile(Output).attributes=0
- objFSO.DeleteFile(Output)
- End If
- objFSO.CreateTextFile(Output,2).Write Chr(80)&Chr(75)&Chr(5)&Chr(6)&String(18,Chr(0))
- CreateObject("Shell.Application").NameSpace(Output).CopyHere tempmakingfolder&"\"&"mimetype"
- Wscript.sleep 100
- CreateObject("Shell.Application").NameSpace(Output).CopyHere metainffolder
- Wscript.sleep 100
- CreateObject("Shell.Application").NameSpace(Output).CopyHere oebpsfolder
- Wscript.sleep 1500
- If inputfiledelete=1 Then
- objFSO.DeleteFile(Input)
- If objFSO.FolderExists(imgfolder) Then objFSO.DeleteFolder(imgfolder)
- If objFSO.FolderExists(fntfolder) Then objFSO.DeleteFolder(fntfolder)
- End If
- Wscript.echo "done"
- If objFSO.FileExists(OutputEpub) Then objFSO.DeleteFile(OutputEpub)
- objFSO.GetFile(Output).move(OutputEpub)
- objFSO.DeleteFolder(tempmakingfolder)
- WshShell.run epubcontentpreview,1,True
- objFSO.DeleteFile(epubcontentpreview)
- Wscript.quit
- Function CheckFootnote(a)
- CheckFootnote=EMPTY
- For kw=0 To UBound(arrfootnote)
- If a=arrfootnote(kw) Then
- CheckFootnote=1
- Exit For
- End If
- Next
- End Function
- Function CheckIntro(a)
- CheckIntro=EMPTY
- For kw=0 To UBound(arrintro)
- If a=arrintro(kw) Then
- CheckIntro=1
- Exit For
- End If
- Next
- End Function
- Function CheckAuthor(a)
- CheckAuthor=EMPTY
- For kw=0 To UBound(arrauthor)
- If a=arrauthor(kw) Then
- CheckAuthor=1
- Exit For
- End If
- Next
- End Function
- Function CheckInfo(a)
- CheckInfo=EMPTY
- For kw=0 To UBound(arrinfo)
- If a=arrinfo(kw) Then
- CheckInfo=1
- Exit For
- End If
- Next
- End Function
- Function CheckAut(a)
- For kw=0 To UBound(arraut)
- If Left(a,5)=arraut(kw) Then author=Trim(Mid(a,6))
- If Left(a,4)=arraut(kw) Then author=Trim(Mid(a,5))
- If Left(a,3)=arraut(kw) Then author=Trim(Mid(a,4))
- If author<>EMPTY Then Exit For
- Next
- End Function
- Function CheckGak(a)
- For kw=0 To UBound(arrgak)
- If Left(a,4)=arrgak(kw) Then author2=Trim(Mid(a,5))
- If Left(a,3)=arrgak(kw) Then author2=Trim(Mid(a,4))
- If author2<>EMPTY Then Exit For
- Next
- End Function
- Function CheckLabel(a)
- CheckLabel=EMPTY
- For kw=0 To UBound(arrlabel)
- If LCase(a)=arrlabel(kw) Then
- CheckLabel=1
- Exit For
- End If
- Next
- End Function
- Function CheckSymbol(a)
- CheckSymbol=EMPTY
- For cls=1 To Len(a)
- For kw=0 To UBound(arrsymbol)
- If Mid(a,cls,1)=arrsymbol(kw) Then
- SymbolStat=1
- Exit For
- Else
- SymbolStat=EMPTY
- End If
- Next
- If SymbolStat=EMPTY Then
- Exit For
- End If
- Next
- If SymbolStat=1 Then CheckSymbol=1
- End Function
- Function ReplaceEsc(a)
- Do
- a1=InStr(a,"<")
- a2=0
- If a1>0 Then
- b=b&Left(a,a1-1)
- a=Right(a,Len(a)-a1+1)
- a2=InStr(a,">")
- If a2>0 Then
- ab=Left(a,a2)
- a=Right(a,Len(a)-a2)
- abtrim=Mid(ab,2,Len(ab)-2)
- If CheckLabel(ab)=EMPTY Then
- If Left(ab,4)<>"<img" and Left(ab,5)<>"<span" and Left(ab,6)<>"<audio" and Left(ab,6)<>"video" and Left(ab,7)<>"<source" Then
- ab="<"&abtrim&">"
- End If
- End If
- End If
- End If
- b=b&ab
- ab=EMPTY
- abtrim=EMPTY
- Loop while a2>0
- b=b&a
- ReplaceEsc=b
- End Function
- Function Utf8Convert(UnicodeFile)
- objAdodbStream.Charset="Unicode"
- objAdodbStream.Open
- objAdodbStream.LoadFromFile UnicodeFile
- OutputText = objAdodbStream.ReadText
- objAdodbStream.Close
- objAdodbStream.Charset="Utf-8"
- objAdodbStream.Open
- objAdodbStream.WriteText OutputText
- objAdodbStream.SaveToFile UnicodeFile,2
- objAdodbStream.Close
- End Function
- Function ReplaceRuby(a)
- Do
- a1=InStr(a,rubya)
- If a1>0 Then
- b=Right(a,Len(a)-a1)
- a=Left(a,a1-1)
- b1=InStr(b,rubyb)
- b2=InStr(b,rubya)
- If b1>0 Then
- c=Right(b,Len(b)-b1)
- b=Left(b,b1-1)
- c1=InStr(c,rubyc)
- If c1=0 Then
- rubyerror=rubyerror+1
- End If
- If c1>0 Then
- d=Right(c,Len(c)-c1)
- c=Left(c,c1-1)
- If b=EMPTY or c=EMPTY Then
- rubyerror=rubyerror+1
- End If
- End If
- End If
- End If
- rubyint="<ruby>"
- rubymid="<rt>"
- rubyend="</rt></ruby>"
- If b<>EMPTY and c<>EMPTY Then
- rubystr=1
- rubycount=rubycount+1
- rubyinlinestr=rubyint&b&rubymid&c&rubyend
- rubyspanstr="<span id=""ruby"&rubycount&""">"&rubyinlinestr&"</span>"
- a=a&rubyspanstr&d
- b3=InStr(c,rubya)
- b4=InStr(c,rubyb)
- b5=InStr(b,rubya)
- b6=InStr(b,rubyc)
- If b3>0 or b4>0 or b5>0 or b6>0 Then
- rubyerror=rubyerror+1
- End If
- If b1>0 and b2>0 Then
- If b1>b2 Then
- rubyerror=rubyerror+1
- End If
- End If
- If rubystr=1 and rubytablestat=1 Then
- rubytablehtmlfn=rubyhref
- rubyhrefstr="<a href="""&rubytablehtmlfn&"#ruby"&rubycount&""">"&rubyinlinestr&"</a>"
- rubytexthtmlstr=rubytexthtmlstr&" "&rubyhrefstr
- If rubycount=1 Then
- rubytexthtmlstr=rubyhrefstr
- End If
- rubyhrefstr=EMPTY
- rubytablehtmlfn=EMPTY
- End If
- Else
- a=a&b&c&d
- rubystr=EMPTY
- End If
- a1=EMPTY
- b1=EMPTY
- c1=EMPTY
- b=EMPTY
- c=EMPTY
- d=EMPTY
- b2=EMPTY
- b3=EMPTY
- b4=EMPTY
- b5=EMPTY
- b6=EMPTY
- Loop while rubystr=1
- ReplaceRuby=a
- End Function
- Function FilterRubyLabel(a)
- Do
- rubyfilter=EMPTY
- For i=1 To Len(a)-5
- If LCase(Mid(a,i,6))="<ruby>" Then
- b=Right(a,Len(a)-i+1)
- a=Left(a,i-1)
- b1=Right(b,Len(b)-6)
- b2=Instr(b1,"<")
- If b2>0 Then
- b3=Left(b1,b2-1)
- For r=1 To Len(b)-6
- If LCase(Mid(b,r,7))="</ruby>" Then
- c=Right(b,Len(b)-r-6)
- b=Left(b,r-1)
- rubyfilter=1
- Exit For
- End If
- Next
- End If
- End If
- If rubyfilter=1 Then
- Exit For
- End If
- Next
- If rubyfilter=1 Then
- a=a&b3&c
- Else
- a=a&b
- End If
- b=EMPTY
- c=EMPTY
- Loop while rubyfilter=1
- FilterRubyLabel=a
- End Function
- Function FilterHtmlLabel(a)
- Do
- a1=InStr(a,"<")
- a2=0
- If a1>0 Then
- b=b&Left(a,a1-1)
- a=Right(a,Len(a)-a1+1)
- a2=InStr(a,">")
- If a2>0 Then
- ab=Left(a,a2)
- a=Right(a,Len(a)-a2)
- If CheckLabel(ab)=1 Then
- ab=EMPTY
- End If
- End If
- End If
- b=b&ab
- ab=EMPTY
- Loop while a2>0
- b=b&a
- FilterHtmlLabel=b
- End Function
- Function FilterRubyText(a)
- Do
- rubytext=EMPTY
- efa=a
- For i=1 To Len(a)
- If Mid(a,i,1)=rubya Then
- b=Right(a,Len(a)-i)
- efb=Right(a,Len(a)-i+1)
- efa=Left(a,i-1)
- For r=1 To Len(b)
- If Mid(b,r,1)=rubyb Then
- c=Right(b,Len(b)-r)
- For w=1 To Len(c)
- If Mid(c,w,1)=rubyc Then
- efd=Right(c,Len(c)-w)
- efc=Left(c,w-1)
- efb=Left(b,r-1)
- rubytext=1
- Exit For
- End If
- Next
- End If
- If rubytext=1 Then
- Exit For
- End If
- Next
- End If
- If rubytext=1 Then
- Exit For
- End If
- Next
- a=efa&efb&efd
- efa=EMPTY
- efb=EMPTY
- efc=EMPTY
- efd=EMPTY
- Loop while rubytext=1
- FilterRubyText=a
- End Function
- Function CheckTagpSkip(a)
- If a="<br/>" or a="<br />" or Left(a,4)="<hr " or Left(a,3)="<p>" or Left(a,3)="<p " or Left(a,4)="<div" Then
- CheckTagpSkip=1
- End If
- End Function
- Function ReplaceFootnote(a,HonnTaiLine,BunShinLine)
- Do
- footnotestr=EMPTY
- For i=1 To Len(a)-2
- b=Mid(a,i,3)
- a1=Mid(a,1,i-1)
- a2=Mid(a,i)
- b1=Left(b,1)
- b2=Mid(b,2,1)
- b3=Right(b,1)
- If b1="(" or b1="(" Then
- If CheckFootnote(b2)=1 Then
- If b3=":" or b3=":" or b3="︰" Then
- footnotestat=1
- footnotestrlen=1
- End If
- End If
- End If
- If footnotestat=EMPTY Then
- b=Mid(a,i,4)
- a1=Mid(a,1,i-1)
- a2=Mid(a,i)
- b1=Left(b,1)
- b2=Mid(b,2,2)
- b3=Right(b,1)
- If b1="(" or b1="(" Then
- If CheckFootnote(b2)=1 Then
- If b3=":" or b3=":" or b3="︰" Then
- footnotestat=1
- footnotestrlen=2
- End If
- End If
- End If
- End If
- If footnotestat=EMPTY Then
- b=Mid(a,i,5)
- a1=Mid(a,1,i-1)
- a2=Mid(a,i)
- b1=Left(b,1)
- b2=Mid(b,2,3)
- b3=Right(b,1)
- If b1="(" or b1="(" Then
- If CheckFootnote(b2)=1 Then
- If b3=":" or b3=":" or b3="︰" Then
- footnotestat=1
- footnotestrlen=3
- End If
- End If
- End If
- End If
- If footnotestat=1 Then
- If b1="(" Then be1=")"
- If b1="(" Then be1=")"
- be=Instr(a2,be1)
- a3=Mid(a2,2)
- be2=Instr(a3,b1)
- If be>0 and be2>0 Then
- If be>be2 Then
- footnoteerror=footnoteerror+1
- End If
- End If
- If be=0 Then
- footnoteerror=footnoteerror+1
- End If
- If be>0 Then
- If footnotestrlen=1 Then
- c=Mid(a,i+be)
- d=Mid(a,i+1,be-2)
- End If
- If footnotestrlen=2 Then
- c=Mid(a,i+be)
- d=Mid(a,i+1,be-2)
- End If
- If footnotestrlen=3 Then
- c=Mid(a,i+be)
- d=Mid(a,i+1,be-2)
- End If
- footnotestr=1
- footnotecount=footnotecount+1
- footnotestatd=footnotestatd+1
- End If
- End If
- If footnotestr=1 Then
- If footnotetype="duokan" Then
- bn="<a class=""duokan-footnote"" href=""#duokanfootnote"&footnotecount&"""><img class=""footnote-img"" src=""../Images/footnote.png""/></a>"
- a=a1&bn&c
- If footnotestatd=1 Then
- d="<ol class=""duokan-footnote-content"">"&vbcrlf&"<li class=""duokan-footnote-item"" id=""duokanfootnote"&footnotecount&"""><p class=""footnote-text"">"&d&"</p></li>"
- Else
- d="<li class=""duokan-footnote-item"" id=""duokanfootnote"&footnotecount&"""><p class=""footnote-text"">"&d&"</p></li>"
- End If
- e=e&d&vbcrlf
- End If
- If footnotetype="newline" Then
- bn="<img class=""footnote-img"" src=""../Images/footnote.png"" id=""footnote"&footnotecount&"""/>"
- a=a1&bn&c
- d="<div class=""footnote-text align-left border-dashed-color"">"&d&"</div>"
- e=e&d&vbcrlf
- End If
- End If
- a1=EMPTY
- a2=EMPTY
- a3=EMPTY
- b=EMPTY
- b1=EMPTY
- b2=EMPTY
- b3=EMPTY
- be=EMPTY
- be1=EMPTY
- be2=EMPTY
- c=EMPTY
- d=EMPTY
- bn=EMPTY
- footnotestat=EMPTY
- footnotestrlen=EMPTY
- If footnotestr=1 Then
- Exit For
- End If
- Next
- Loop while footnotestr=1
- If footnotetype="duokan" Then
- If footnotestatd>0 Then
- e=e&"</ol>"
- End If
- End If
- HonnTaiLine=a
- BunShinLine=e
- End Function
- Function FilterFootnote(a)
- Do
- footnotestr=EMPTY
- For i=1 To Len(a)-2
- b=Mid(a,i,3)
- a1=Mid(a,1,i-1)
- a2=Mid(a,i)
- b1=Left(b,1)
- b2=Mid(b,2,1)
- b3=Right(b,1)
- If b1="(" or b1="(" Then
- If CheckFootnote(b2)=1 Then
- If b3=":" or b3=":" or b3="︰" Then
- footnotestat=1
- footnotestrlen=1
- End If
- End If
- End If
- If footnotestat=EMPTY Then
- b=Mid(a,i,4)
- a1=Mid(a,1,i-1)
- a2=Mid(a,i)
- b1=Left(b,1)
- b2=Mid(b,2,2)
- b3=Right(b,1)
- If b1="(" or b1="(" Then
- If CheckFootnote(b2)=1 Then
- If b3=":" or b3=":" or b3="︰" Then
- footnotestat=1
- footnotestrlen=2
- End If
- End If
- End If
- End If
- If footnotestat=EMPTY Then
- b=Mid(a,i,5)
- a1=Mid(a,1,i-1)
- a2=Mid(a,i)
- b1=Left(b,1)
- b2=Mid(b,2,3)
- b3=Right(b,1)
- If b1="(" or b1="(" Then
- If CheckFootnote(b2)=1 Then
- If b3=":" or b3=":" or b3="︰" Then
- footnotestat=1
- footnotestrlen=3
- End If
- End If
- End If
- End If
- If footnotestat=1 Then
- If b1="(" Then be1=")"
- If b1="(" Then be1=")"
- be=Instr(a2,be1)
- If be>0 Then
- c=Mid(a,i+be)
- a=a1&c
- footnotestr=1
- End If
- End If
- a1=EMPTY
- a2=EMPTY
- b=EMPTY
- b1=EMPTY
- b2=EMPTY
- b3=EMPTY
- be=EMPTY
- be1=EMPTY
- c=EMPTY
- footnotestat=EMPTY
- footnotestrlen=EMPTY
- If footnotestr=1 Then
- Exit For
- End If
- Next
- Loop while footnotestr=1
- FilterFootnote=a
- End Function
- Function GetJpegName(a)
- GetJpegName=a
- bsn=objFSO.GetBaseName(a)
- ext=LCase(objFSO.GetExtensionName(a))
- If ext="jpg" or ext="jpeg" Then
- If objFSO.FileExists(imagesfolder&"\"&bsn&".jpg") Then GetJpegName=objFSO.GetFile(imagesfolder&"\"&bsn&".jpg").name
- If objFSO.FileExists(imagesfolder&"\"&bsn&".jpeg") Then GetJpegName=objFSO.GetFile(imagesfolder&"\"&bsn&".jpeg").name
- End If
- End Function
- Function FilterAuthor()
- Set autread = objFSO.OpenTextFile(Input,1,0,-1)
- Do until autread.AtEndOfStream
- autline=Trim(autread.ReadLine)
- If author=EMPTY and autline<>EMPTY Then CheckAut(autline)
- If author2=EMPTY and autline<>EMPTY Then CheckGak(autline)
- If autline=chapterbreak Then Exit Do
- If author<>EMPTY and author2<>EMPTY Then Exit Do
- Loop
- autread.Close
- End Function
复制代码
实际效果:http://ritdon.com/forum.php?mod=viewthread&tid=10011
(txt备份版的epub文件内有用来转换的txt文件,可以对照格式)
这个脚本的打包方式是先创建一个空zip文件,然后把图片及网页文件复制进去,再修改后缀名为epub,用压缩软件打开即可
相当简单的脚本,不保证效果,可能有未知的Bug,请谨慎运行
|
评分
-
查看全部评分
|