This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
852 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace KoeBook.Epub | ||
{ | ||
public class EpubDocumentException : Exception | ||
{ | ||
public EpubDocumentException(string? message) : base(message) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System.Net; | ||
using System.Reflection.Metadata; | ||
|
||
namespace KoeBook.Epub; | ||
|
||
internal static class ScrapingHelper | ||
{ | ||
internal static void checkChapter(EpubDocument document) | ||
{ | ||
if (document.Chapters.Count == 0) | ||
{ | ||
document.Chapters.Add(new Chapter() { Title = null }); | ||
} | ||
return; | ||
} | ||
|
||
internal static void checkSection(EpubDocument document, int ChapterNum) | ||
{ | ||
|
||
checkChapter(document); | ||
|
||
if (document.Chapters[ChapterNum].Sections.Count == 0) | ||
{ | ||
if (document.Chapters[ChapterNum].Title != null) | ||
{ | ||
document.Chapters[ChapterNum].Sections.Add(new Section(document.Chapters[ChapterNum].Title!)); | ||
} | ||
else | ||
{ | ||
document.Chapters[ChapterNum].Sections.Add(new Section(document.Title)); | ||
} | ||
|
||
} | ||
return; | ||
} | ||
|
||
internal static void checkParagraph(EpubDocument document, int chapterNum, int sectionNum) | ||
{ | ||
checkSection(document, chapterNum); | ||
if (document.Chapters[chapterNum].Sections[sectionNum].Elements.Count == 0) | ||
{ | ||
document.Chapters[chapterNum].Sections[sectionNum].Elements.Add(new Paragraph()); | ||
} | ||
return; | ||
} | ||
|
||
public static List<string> SplitBrace(string text) | ||
{ | ||
var result = new List<string>(); | ||
int bracket = 0; | ||
var brackets = new List<int>(); | ||
foreach (char c in text) | ||
{ | ||
if (c == '「') bracket++; | ||
if (c == '」') bracket--; | ||
brackets.Add(bracket); | ||
} | ||
var mn = Math.Min(0, brackets.Min()); | ||
int startIdx = 0; | ||
for (int i = 0; i < brackets.Count; i++) | ||
{ | ||
brackets[i] -= mn; | ||
if (text[i] == '「' && brackets[i] == 1 && i != 0) | ||
{ | ||
result.Add(text[startIdx..(i - startIdx)]); | ||
startIdx = i; | ||
} | ||
if (text[i] == '」' && brackets[i] == 0 && i != 0) | ||
{ | ||
result.Add(text[startIdx..(i - startIdx + 1)]); | ||
startIdx = i + 1; | ||
} | ||
} | ||
if (startIdx != text.Length - 1) | ||
{ | ||
result.Add(text[startIdx..]); | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"$schema": "https://aka.ms/CsWin32.schema.json", | ||
"public": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MessageBox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters