• R/O
  • SSH
  • HTTPS

autocodeforsql: 提交


Commit MetaInfo

修订版401 (tree)
时间2020-11-05 13:30:29
作者hilinwei

Log Message

更改概述

差异

--- AutoEpub3/Logic/DEP3/cDep3_006.vb (revision 400)
+++ AutoEpub3/Logic/DEP3/cDep3_006.vb (revision 401)
@@ -20,7 +20,6 @@
2020
2121 Public Sub CreadEpub()
2222
23-
2423 Dim sText As String = String.Empty
2524 Dim listLine As New List(Of String)
2625
@@ -44,12 +43,8 @@
4443 Continue For
4544 End If
4645
47-
4846 mSection.Title = mSection.Title.Split("(")(1).Replace(")", "").Replace("岩波日本史", "") & " " & mSection.Title.Split("(")(0)
4947
50-
51-
52-
5348 If ncxSection.navPoint Is Nothing Then
5449
5550 mSection.Title = ncxSection.navLabel.text
@@ -146,113 +141,103 @@
146141
147142 End Sub
148143
144+ Private Function GetListText(ByVal sHtml) As List(Of String)
149145
146+ GetListText = New List(Of String)
147+ Dim apHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
148+ apHtml.LoadHtml(sHtml)
149+ Dim listHtmlNode = apHtml.DocumentNode.Descendants.Where(Function(x) x.Name = "p" OrElse x.Name = "h3" OrElse x.Name = "img")
150+ For Each uHtmlNode As HtmlAgilityPack.HtmlNode In listHtmlNode
150151
151- Private Function sFileEditRead(ByVal sPath As String, ByVal KBN_DEP As emEpub6.emDep) As String
152- sFileEditRead = cTools.sFileReader(sPath, cEpub6.encUTF8)
152+ If uHtmlNode.Name = "p" Then
153+ Dim sTarget As String = uHtmlNode.InnerHtml
154+ If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then
155+ sTarget = sTarget + emEpub6.spDl_Right
156+ End If
157+ GetListText.Add(sTarget)
158+ End If
153159
154- 'DelHtml(sFileEditRead)
160+ If uHtmlNode.Name = "h3" Then
161+ Dim sTarget As String = uHtmlNode.InnerHtml
162+ If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then
163+ sTarget = sTarget + emEpub6.spDl_Right
164+ End If
165+ GetListText.Add(sTarget)
166+ End If
155167
156- 'EditHref00(sFileEditRead)
157- 'EditHref01(sFileEditRead)
158- 'EditHref02(sFileEditRead)
159- 'EditHref03(sFileEditRead)
160- ResetImgUrl(sFileEditRead)
161168
162- End Function
169+ If uHtmlNode.Name = "img" Then
163170
171+ Dim imgScr As String = uHtmlNode.Attributes("src").Value
172+ Dim sNewImg As String = cTools.sGaiji(imgScr, emCurreDep)
173+ If uHtmlNode.OuterHtml.IndexOf("image-100") > -1 Then
174+ sNewImg = cTools.sMapImg(imgScr, emCurreDep)
175+ End If
176+ GetListText.Add(sNewImg)
177+ End If
164178
165- Private Sub DelHtml(ByRef sHtml As String)
166179
167- 'Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
168- 'Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
169- 'hapHtml.LoadHtml(sHtmlFormat)
170- 'Dim listDel1 = hapHtml.DocumentNode.SelectNodes(("//div[contains(@class, 'calibre1')]"))
180+ Next
171181
172- 'If listDel1 IsNot Nothing Then
173- ' For Each uDel As HtmlAgilityPack.HtmlNode In listDel1
174- ' Console.WriteLine(uDel.InnerText)
175- ' sHtml = sHtml.Replace(uDel.OuterHtml, "")
176- ' Next
177- 'End If
182+ End Function
178183
179184
185+ Private Function sFileEditRead(ByVal sPath As String, ByVal KBN_DEP As emEpub6.emDep) As String
186+ sFileEditRead = cTools.sFileReader(sPath, cEpub6.encUTF8)
180187
181- 'Dim listDel2 = hapHtml.DocumentNode.SelectNodes(("//h[contains(@class, 'calibre8')]"))
188+ DelHtml(sFileEditRead)
182189
183- 'If listDel2 IsNot Nothing Then
184- ' For Each uDel As HtmlAgilityPack.HtmlNode In listDel2
185- ' Console.WriteLine(uDel.InnerText)
186- ' sHtml = sHtml.Replace(uDel.OuterHtml, "")
187- ' Next
188- 'End If
190+ EditHref00(sFileEditRead)
191+ EditHref01(sFileEditRead)
192+ EditHref02(sFileEditRead)
193+ EditHref03(sFileEditRead)
194+ ResetImgUrl(sFileEditRead)
189195
196+ End Function
190197
191198
199+ Private Sub DelHtml(ByRef sHtml As String)
192200
193201
194-
195202 End Sub
196203
197204 Private Sub EditHref00(ByRef sHtml As String)
198205
199- End Sub
206+ Dim hapHtmlEdit As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
207+ hapHtmlEdit.LoadHtml(sHtml)
208+ Dim linqHap = hapHtmlEdit.DocumentNode.SelectNodes(("//a"))
200209
210+ If linqHap IsNot Nothing Then
201211
202- Private Sub EditHref01(ByRef sHtml As String)
212+ For Each uHap As HtmlNode In linqHap
203213
214+ Dim sScr As String = uHap.Attributes("href").Value
204215
205- Dim hapHtmlSub As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
216+ If sScr.Split("#").Count = 2 Then
217+ sHtml = sHtml.Replace(sScr, "#" & sScr.Split("#")(1))
218+ Else
219+ Dim sError As String = ""
220+ End If
221+ Next
206222
223+ End If
207224
208- Dim listHdr = hapHtmlSub.DocumentNode.SelectNodes(("//a"))
209225
226+ End Sub
210227
211- Dim kke = 1
212228
229+ Private Sub EditHref01(ByRef sHtml As String)
213230
214- 'Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
215- 'Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
216- 'hapHtml.LoadHtml(sHtmlFormat)
217-
218- 'Dim listMemoC = hapHtml.DocumentNode.SelectNodes(("//span"))
219- 'Dim listMemoM = hapHtml.DocumentNode.SelectNodes(("//a[contains(@class, 'calibre2')]"))
220-
221- 'If listMemoM Is Nothing OrElse listMemoC Is Nothing Then
222- ' Exit Sub
223- 'End If
224-
225-
226-
227- 'If listMemoC.Count = listMemoM.Count Then
228-
229- ' For iMemo As Integer = 0 To listMemoC.Count - 1
230-
231- ' Dim sNewC As String = "<a id=""w" & iMemo.ToString().PadLeft(2, "0") & """ href=""#m" & iMemo.ToString().PadLeft(2, "0") & """><sup>[" & (iMemo + 1).ToString().PadLeft(2, "0") & "]</sup></a>"
232-
233- ' Dim sNewM As String = "<a id=""m" & iMemo.ToString().PadLeft(2, "0") & """ href=""#w" & iMemo.ToString().PadLeft(2, "0") & """>[" & (iMemo + 1).ToString().PadLeft(2, "0") & "]</a>"
234-
235- ' sHtml = sHtml.Replace(listMemoC(iMemo).OuterHtml, sNewC)
236-
237- ' sHtml = sHtml.Replace(listMemoM(iMemo).OuterHtml, sNewM)
238-
239- ' Next
240- 'Else
241- ' Throw New Exception(listMemoC.Count & ":" & listMemoM.Count)
242- 'End If
243-
244231 End Sub
245232
246233
247234 Private Sub EditHref02(ByRef sHtml As String)
248235
249-
250236 End Sub
251237
252238
253239 Private Sub EditHref03(ByRef sHtml As String)
254240
255-
256241 End Sub
257242
258243
@@ -386,7 +371,7 @@
386371 Dim imgScr As String = uTarget.Attributes("src").Value
387372 Dim sNewImg As String = cTools.sGaiji(imgScr, emCurreDep)
388373 If uTarget.OuterHtml.IndexOf("image-100") > -1 Then
389- sNewImg = cTools.sMapImg(sNewImg, emEpub6.emUrlImgDep.Volume)
374+ sNewImg = cTools.sMapImg(sNewImg, emCurreDep )
390375 End If
391376 sChapter = sChapter.Replace(uTarget.OuterHtml, sNewImg)
392377 Next
@@ -393,46 +378,4 @@
393378 End If
394379 End Sub
395380
396-
397- Private Function GetListText(ByVal sHtml) As List(Of String)
398-
399- GetListText = New List(Of String)
400- Dim apHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
401- apHtml.LoadHtml(sHtml)
402- Dim listHtmlNode = apHtml.DocumentNode.Descendants.Where(Function(x) x.Name = "p" OrElse x.Name = "h3" OrElse x.Name = "img")
403- For Each uHtmlNode As HtmlAgilityPack.HtmlNode In listHtmlNode
404-
405- If uHtmlNode.Name = "p" Then
406- Dim sTarget As String = uHtmlNode.InnerHtml
407- If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then
408- sTarget = sTarget + emEpub6.spDl_Right
409- End If
410- GetListText.Add(sTarget)
411- End If
412-
413- If uHtmlNode.Name = "h3" Then
414- Dim sTarget As String = uHtmlNode.InnerHtml
415- If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then
416- sTarget = sTarget + emEpub6.spDl_Right
417- End If
418- GetListText.Add(sTarget)
419- End If
420-
421-
422- If uHtmlNode.Name = "img" Then
423- Dim sTarget As String = uHtmlNode.InnerHtml
424- If listMobiRight.Any(Function(x) uHtmlNode.OuterHtml.Contains(x)) Then
425- sTarget = sTarget + emEpub6.spDl_Right
426- End If
427- GetListText.Add(sTarget)
428- End If
429-
430-
431- Next
432-
433- End Function
434-
435-
436-
437-
438381 End Class
--- AutoEpub3/cTools.vb (revision 400)
+++ AutoEpub3/cTools.vb (revision 401)
@@ -1367,7 +1367,7 @@
13671367 sScr = "Img/" & listTemp(listTemp.Count - 1)
13681368
13691369 If iDep = emEpub6.emUrlImgDep.Section Then
1370- sScr = "../../../" & sScr
1370+ sScr = "../" & sScr
13711371 End If
13721372
13731373 If iDep = emEpub6.emUrlImgDep.Volume Then
@@ -1375,7 +1375,7 @@
13751375 End If
13761376
13771377 If iDep = emEpub6.emUrlImgDep.Chapter Then
1378- sScr = "../" & sScr
1378+ sScr = "../../../" & sScr
13791379 End If
13801380
13811381 sMapImg = "<img Class=""mobiImgMap"" alt="""" src=""" & sScr & """/>"
Show on old repository browser