• R/O
  • SSH
  • HTTPS

autocodeforsql: Commit


Commit MetaInfo

Revisão379 (tree)
Hora2020-09-11 10:34:17
Autorhilinwei

Mensagem de Log

Mudança Sumário

Diff

--- AutoEpub3/Logic/DEP3/cDep3_003.vb (revision 378)
+++ AutoEpub3/Logic/DEP3/cDep3_003.vb (revision 379)
@@ -18,6 +18,7 @@
1818
1919 Public Sub CreadEpub()
2020
21+
2122 Dim sText As String = String.Empty
2223 Dim listLine As New List(Of String)
2324
@@ -83,16 +84,15 @@
8384
8485 Dim sPath As String = Path.Combine(bookPath, ncxChapter.content.src).Split("#").ToList(0)
8586
86- Dim sVolume As String = cTools.sFileReader(sPath, cEpub6.encUTF8)
87- sReplaceHtml(sVolume, emEpub6.emUrlImgDep.Volume)
87+ Dim sVolume As String = sFileEditRead(sPath, emEpub6.emDep.Dep2)
8888
8989 Dim listText As List(Of String) = cTools.listText_P(sVolume)
9090
91- If listText.Count > 0 Then
92- If listText(0).Trim().IndexOf(mVolume.Title) > -1 Then
93- listText.RemoveAt(0)
94- End If
95- End If
91+ 'If listText.Count > 0 Then
92+ ' If listText(0).Trim().IndexOf(mVolume.Title) > -1 Then
93+ ' listText.RemoveAt(0)
94+ ' End If
95+ 'End If
9696
9797
9898 mVolume.listText = listText
@@ -119,17 +119,16 @@
119119
120120 Dim sPath As String = Path.Combine(bookPath, mChapter.Scr).Split("#").ToList(0)
121121
122- Dim sChapter As String = cTools.sFileReader(sPath, cEpub6.encUTF8)
123- sReplaceHtml(sChapter, emEpub6.emUrlImgDep.Section)
122+ Dim sChapter As String = sFileEditRead(sPath, emEpub6.emDep.Dep3)
124123 Dim listText As List(Of String) = cTools.listText_P(sChapter)
125124
126125 mChapter.listText = listText
127126
128- If listText.Count > 0 Then
129- If listText(0).Trim().IndexOf(mVolume.Title) > -1 Then
130- listText.RemoveAt(0)
131- End If
132- End If
127+ 'If listText.Count > 0 Then
128+ ' If listText(0).Trim().IndexOf(mVolume.Title) > -1 Then
129+ ' listText.RemoveAt(0)
130+ ' End If
131+ 'End If
133132
134133
135134 mVolume.listChapter.Add(mChapter)
@@ -150,34 +149,19 @@
150149
151150 mEpub.RemoveAt(6)
152151
153- chkEPUB001("href")
154152
155- End Sub
153+ ReMoveTopTitle()
156154
157- Private Sub ResetImgUrl(ByRef sChapter As String)
155+ 'chkEPUB001("href")
158156
157+ End Sub
159158
160159
161- Dim listImg As List(Of String) = cTools.listNav_SE(sChapter, "<img", "/>", True)
162- For Each eachImg As String In listImg
163- Dim sScr As String = eachImg.Split("/").ToList()(2).Split("""").ToList()(0)
164- Dim sNewImg As String = cTools.sGaiji(sScr, emEpub6.emUrlImgDep.Volume)
165-
166- If eachImg.IndexOf("calibre20") > -1 Then
167- sNewImg = cTools.sMapImg(sScr, emEpub6.emUrlImgDep.Volume)
168- End If
169-
170- sChapter = sChapter.Replace(eachImg, sNewImg)
171- Next
172-
173-
174- End Sub
175-
176160 Private Function addSection() As modelSection
177161
178162 addSection = New modelSection
179163
180- addSection.Title = "盛夏的方程式2"
164+ addSection.Title = "盛夏的方程式"
181165
182166 Dim sPath As String = "C:\Users\DTC_PC07\Downloads\BS1\"
183167
@@ -200,23 +184,13 @@
200184 Continue For
201185 End If
202186
203- Dim sChapter As String = cTools.sFileReader(sPath & mVolume.Scr, cEpub6.encUTF8)
187+ Dim sChapter As String = sFileEditRead(sPath & mVolume.Scr, emEpub6.emDep.Dep3)
204188
205- DelHtml(sChapter)
206- Edithref(sChapter)
207-
208189 Dim listText As List(Of String) = cTools.listText_P(sChapter)
209190
210- 'If listText.Count > 0 Then
211- ' If listText(0).Trim().IndexOf(mVolume.Title) > -1 Then
212- ' listText.RemoveAt(0)
213- ' End If
214- 'End If
215-
216-
217191 mVolume.listText = listText
218192
219-
193+ 'chkListTopLine(mVolume.listText, mVolume.Title)
220194 addSection.listVolume.Add(mVolume)
221195 Next
222196
@@ -231,38 +205,46 @@
231205 End Function
232206
233207
234- Private Sub sReplaceHtml(ByRef sHtml As String, ByVal kbnDep As emEpub6.emUrlImgDep)
235- sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00076.jpg"" />" & vbCrLf & " ", "坚")
236- sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00015.jpg"" />" & vbCrLf & " ", "坚")
237- sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00017.jpg"" />" & vbCrLf & " ", "坚")
238- sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00016.jpg"" />" & vbCrLf & " ", "坚")
239- sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00016.jpg"" />" & vbCrLf & " ", "坚")
240- sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00018.jpg"" />" & vbCrLf & " ", "坚")
241- ResetImgUrl(sHtml, kbnDep)
242208
243- Dim listMemo As List(Of String) = cTools.listNav_SE(sHtml, "<a", "</a>", True)
244- If listMemo.Count > 0 Then
245- Dim sStop As String = "1"
246- End If
209+ Private Function sFileEditRead(ByVal sPath As String, ByVal KBN_DEP As emEpub6.emDep) As String
210+ sFileEditRead = cTools.sFileReader(sPath, cEpub6.encUTF8)
247211
248- End Sub
212+ DelHtml(sFileEditRead)
249213
214+ EditHref00(sFileEditRead)
215+ EditHref01(sFileEditRead)
216+ EditHref02(sFileEditRead)
217+ EditHref03(sFileEditRead)
218+
219+ End Function
220+
221+
250222 Private Sub DelHtml(ByRef sHtml As String)
251223
252224 Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
253225 Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
254226 hapHtml.LoadHtml(sHtmlFormat)
255- Dim listDel1 As HtmlAgilityPack.HtmlNode() = hapHtml.DocumentNode.SelectNodes(("//div[contains(@class, 'calibre1')]")).ToArray()
227+ Dim listDel1 = hapHtml.DocumentNode.SelectNodes(("//div[contains(@class, 'calibre1')]"))
256228
257- For Each uDel As HtmlAgilityPack.HtmlNode In listDel1
229+ If listDel1 IsNot Nothing Then
230+ For Each uDel As HtmlAgilityPack.HtmlNode In listDel1
231+ sHtml = sHtml.Replace(uDel.OuterHtml, "")
232+ Next
233+ End If
258234
259- sHtml = sHtml.Replace(uDel.OuterHtml, "")
260- Next
235+ End Sub
261236
237+ Private Sub EditHref00(ByRef sHtml As String)
238+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00076.jpg"" />" & vbCrLf & " ", "坚")
239+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00015.jpg"" />" & vbCrLf & " ", "坚")
240+ sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00017.jpg"" />" & vbCrLf & " ", "坚")
241+ sHtml = sHtml.Replace("<img class=""calibre_14"" src=""Image00016.jpg"" />" & vbCrLf & " ", "坚")
242+ sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00016.jpg"" />" & vbCrLf & " ", "坚")
243+ sHtml = sHtml.Replace("<img class=""calibre_15"" src=""Image00018.jpg"" />" & vbCrLf & " ", "坚")
262244 End Sub
263245
264246
265- Private Sub Edithref(ByRef sHtml As String)
247+ Private Sub EditHref01(ByRef sHtml As String)
266248
267249 Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
268250 Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
@@ -297,15 +279,18 @@
297279 End Sub
298280
299281
300- Private Sub Edithref2(ByRef sHtml As String)
282+ Private Sub EditHref02(ByRef sHtml As String)
301283
302284 Dim sHtmlFormat As String = System.Xml.Linq.XElement.Parse(sHtml).ToString()
303285 Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
304286 hapHtml.LoadHtml(sHtmlFormat)
305287
306- Dim listMemoC = hapHtml.DocumentNode.SelectNodes(("//span"))
307- Dim listMemoM = hapHtml.DocumentNode.SelectNodes(("//a[contains(@class, 'calibre2')]"))
288+ Dim listMemoC = hapHtml.DocumentNode.SelectNodes(("//sup[contains(@class, 'calibre48')]"))
289+ Dim listMemoM = hapHtml.DocumentNode.SelectNodes(("//p[contains(@class, 'calibre_16')]"))
308290
291+
292+
293+
309294 If listMemoM Is Nothing OrElse listMemoC Is Nothing Then
310295 Exit Sub
311296 End If
@@ -314,15 +299,27 @@
314299
315300 If listMemoC.Count = listMemoM.Count Then
316301
302+
303+
317304 For iMemo As Integer = 0 To listMemoC.Count - 1
318305
306+ Dim hapHtmlSub As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
307+ hapHtmlSub.LoadHtml(listMemoM(iMemo).InnerHtml)
308+
309+ Dim listMemoSub As String = hapHtmlSub.DocumentNode.SelectNodes(("//span"))(1).InnerText
310+
311+
312+
313+
314+
315+
319316 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>"
320317
321318 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>"
322319
323- sHtml = sHtml.Replace(listMemoC(iMemo).OuterHtml, sNewC)
320+ sHtml = sHtml.Replace(listMemoC(iMemo).InnerHtml, sNewC)
324321
325- sHtml = sHtml.Replace(listMemoM(iMemo).OuterHtml, sNewM)
322+ sHtml = sHtml.Replace(listMemoM(iMemo).InnerHtml, sNewM & listMemoSub)
326323
327324 Next
328325 Else
@@ -332,25 +329,14 @@
332329 End Sub
333330
334331
332+ Private Sub EditHref03(ByRef sHtml As String)
335333
336334
337- Private Sub ResetImgUrl(ByRef sChapter As String, ByVal kbnDep As emEpub6.emUrlImgDep)
335+ End Sub
338336
339- 'Dim listImg As List(Of String) = cTools.listNav_SE(sChapter, "<img", "/>", True)
340- 'For Each eachImg As String In listImg
341- ' Dim sScr As String = eachImg.Split("/").ToList()(2).Split("""").ToList()(0)
342- ' Dim sNewImg As String = cTools.sGaiji(sScr, kbnDep)
343337
344- ' If eachImg.IndexOf("calibre20") > -1 Then
345- ' sNewImg = cTools.sMapImg(sScr, kbnDep)
346- ' End If
347338
348- ' sChapter = sChapter.Replace(eachImg, sNewImg)
349- 'Next
350339
351-
352- End Sub
353-
354340 Public Sub chkEPUB001(ByVal sKey As String)
355341
356342
@@ -429,4 +415,46 @@
429415
430416 End Sub
431417
418+ Private Sub ReMoveTopTitle()
419+
420+
421+ For iCtr1 As Integer = 0 To mEpub.Count - 1
422+
423+ chkListTopLine(mEpub(iCtr1).listText, mEpub(iCtr1).Title)
424+
425+ For iCtr2 As Integer = 0 To mEpub(iCtr1).listVolume.Count - 1
426+
427+ chkListTopLine(mEpub(iCtr1).listVolume(iCtr2).listText, mEpub(iCtr1).listVolume(iCtr2).Title)
428+
429+ For iCtr3 As Integer = 0 To mEpub(iCtr1).listVolume(iCtr2).listChapter.Count - 1
430+ chkListTopLine(mEpub(iCtr1).listVolume(iCtr2).listChapter(iCtr3).listText, mEpub(iCtr1).listVolume(iCtr2).listChapter(iCtr3).Title)
431+ Next
432+ Next
433+ Next
434+
435+ End Sub
436+
437+ Private Sub chkListTopLine(ByRef listText As List(Of String), ByVal sTitle As String)
438+
439+ If listText.Count > 0 AndAlso sTitle.Length > 0 Then
440+ Dim hapHtml As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
441+ hapHtml.LoadHtml(listText(0))
442+ Dim chkNode = hapHtml.DocumentNode.SelectNodes("span")
443+
444+ If chkNode IsNot Nothing Then
445+
446+ If chkNode.Item(0).InnerText.Trim() = sTitle.Trim() Then
447+ listText.RemoveAt(0)
448+ End If
449+
450+ End If
451+
452+
453+ End If
454+
455+
456+ End Sub
457+
458+
459+
432460 End Class
Show on old repository browser