Skip to content

Commit

Permalink
#23 スクレイピング中の情報の扱い方の変更
Browse files Browse the repository at this point in the history
  • Loading branch information
TakenPt committed Apr 23, 2024
1 parent 06b32f1 commit bc0feb1
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,33 @@ private static string GetCardUrl(string url)
return UrlBookToCard().Replace(url, "$1card$2$3");
}

private SplittedLineBuilder ParagraphLineBuilder = new SplittedLineBuilder();
private SplittedLineBuilder ScriptLineLineBuilder = new SplittedLineBuilder();

private int HeadingId = 0;
private Dictionary<string, (int min, int max)> Classes = new Dictionary<string, (int, int)>();
/// <summary>
/// class="main_text"なdiv要素の内容を<paramref name="document"/>に書き込む
/// </summary>
/// <param name="document">書き込むEpubDocument</param>
/// <param name="mainText">class = "main_text" なdiv要素</param>
internal void ProcessMainText(EpubDocument document, IHtmlDivElement mainText)
{
// 青空文庫の見出しのaタグのidの数値に対応
int headingId = 0;

Check warning on line 460 in Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'headingId' is assigned but its value is never used

Check warning on line 460 in Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'headingId' is assigned but its value is never used

Check warning on line 460 in Epub/KoeBook.Epub/Services/ScrapingAozoraService.cs

View workflow job for this annotation

GitHub Actions / test

The variable 'headingId' is assigned but its value is never used
SplittedLineBuilder paragraphLineBuilder = new();
SplittedLineBuilder scriptLineLineBuilder = new();
// 作品中で使われるCSSスタイルを実現するために必要なclassの情報を保持する。
// 例:
// 字下げに使われる class "jisage_1", "jisage_2", ..., "jisage_n"で、 n がいくつになるかは、その作品全体をチェックしないとわからないため、
Dictionary<string, (int min, int max)> classes = new();

//ProcessChildren(); する。
}

/// <summary>
/// ある要素のChildrenに応じた処理を行います
/// EpubDocumentに対してある要素に応じた処理を行う
/// </summary>
/// <param name="document">追加処理を行う対象となるEpubDocument</param>
/// <param name="document">処理対象のEpubDocument</param>
/// <param name="element">処理を行う要素</param>
/// <param name="classes">適用される class のリスト</param>
internal void ProcessChildren(EpubDocument document, IElement element, string classes)
/// <param name="appliedClasses">適用されるclassのリスト</param>
/// <param name="scrapingInfo"></param>
internal void ProcessChildren(EpubDocument document, IElement element, string appliedClasses, int headingId, SplittedLineBuilder paragraphLineBuilder, SplittedLineBuilder scriptLineLineBuilder, Dictionary<string, (int min, int max)> classes)
{

}
Expand All @@ -470,10 +484,10 @@ internal void ProcessChildren(EpubDocument document, IElement element, string cl
/// <see cref="Classes"/>に基づき、EpubDocument内で使用するクラスを生成する。
/// </summary>
/// <param name="document"><see cref="CssClass"/>を変更するEpubDocument</param>
void AddCssClasses(EpubDocument document)
void AddCssClasses(EpubDocument document, Dictionary<string, (int min, int max)> classes)
{
(int min, int max) value = (0, 0);
if (Classes.TryGetValue("jisage", out value))
if (classes.TryGetValue("jisage", out value))
{
for (int i = value.min; i <= value.max; i++)
{
Expand All @@ -484,7 +498,7 @@ void AddCssClasses(EpubDocument document)
"));
}
}
if (Classes.TryGetValue("text_indent", out value))
if (classes.TryGetValue("text_indent", out value))
{
for (int i = value.min; i <= value.max; i++)
{
Expand All @@ -495,7 +509,7 @@ void AddCssClasses(EpubDocument document)
"));
}
}
if (Classes.TryGetValue("chitsuki", out value))
if (classes.TryGetValue("chitsuki", out value))
{
for (int i = value.min; i <= value.max; i++)
{
Expand Down

0 comments on commit bc0feb1

Please sign in to comment.