mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 06:56:10 +00:00
Parsing
This commit is contained in:
parent
c71474ab93
commit
42812a0341
1 changed files with 41 additions and 26 deletions
|
|
@ -381,12 +381,12 @@ namespace AideDeJeuCmd
|
||||||
|
|
||||||
static async Task ExtractHtmlAsync()
|
static async Task ExtractHtmlAsync()
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= 434; i++)
|
for (int i = 10; i <= 428; i++)
|
||||||
{
|
{
|
||||||
var parser = new HtmlParser();
|
var parser = new HtmlParser();
|
||||||
var doc = new HtmlAgilityPack.HtmlDocument();
|
var doc = new HtmlAgilityPack.HtmlDocument();
|
||||||
doc.Load($@"..\..\..\..\..\Ignore\tome_of_beasts\page{i}.html");
|
doc.Load($@"..\..\..\..\..\Ignore\tome_of_beasts\page{i}.html");
|
||||||
parser.OutputMarkdown(parser.Parse(doc));
|
parser.OutputMarkdown(parser.Parse(doc), Console.Out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -479,22 +479,22 @@ namespace AideDeJeuCmd
|
||||||
return fullText;
|
return fullText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OutputMarkdown(FullText fullText)
|
public void OutputMarkdown(FullText fullText, TextWriter output)
|
||||||
{
|
{
|
||||||
bool started = false;
|
bool started = false;
|
||||||
var page = fullText.Where(l => l.FirstOrDefault().Style.Contains("font-size:16px;vertical-align:baseline;color:rgba(255,207,52,1);"))?.FirstOrDefault()?.FirstOrDefault()?.Text;
|
var page = fullText.Where(l => l.FirstOrDefault().Style.Contains("font-size:16px;vertical-align:baseline;color:rgba(255,207,52,1);"))?.FirstOrDefault()?.FirstOrDefault()?.Text;
|
||||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
Console.WriteLine($"Page : {page}");
|
output.WriteLine($"Page : {page}");
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
string abilities = null;
|
string abilities = null;
|
||||||
foreach (var line in fullText)
|
foreach (var line in fullText)
|
||||||
{
|
{
|
||||||
var keySpan = line.FirstOrDefault();
|
var keySpan = line.FirstOrDefault();
|
||||||
if (keySpan.Style.Contains("font-size:11px"))
|
//if (keySpan.Style.Contains("font-size:11px"))
|
||||||
{ // nom (démarrage)
|
//{ // nom (démarrage)
|
||||||
started = true;
|
// started = true;
|
||||||
}
|
//}
|
||||||
if (started)
|
//if (started)
|
||||||
{
|
{
|
||||||
|
|
||||||
string value = "";
|
string value = "";
|
||||||
|
|
@ -502,12 +502,16 @@ namespace AideDeJeuCmd
|
||||||
{
|
{
|
||||||
value = line.Skip(1).Select(p => p.Text).Aggregate((p1, p2) => p1.Trim() + " " + p2.Trim());
|
value = line.Skip(1).Select(p => p.Text).Aggregate((p1, p2) => p1.Trim() + " " + p2.Trim());
|
||||||
}
|
}
|
||||||
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
|
output.Write($"{keySpan.Text}");
|
||||||
|
output.WriteLine($" {value}");
|
||||||
|
|
||||||
if (keySpan.Style.Contains("font-size:11px"))
|
if (keySpan.Style.Contains("font-size:11px"))
|
||||||
{ // nom
|
{ // nom
|
||||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
Console.WriteLine($"# <!--Name-->{keySpan.Text}<!--/Name-->");
|
output.WriteLine($"# <!--Name-->{keySpan.Text}<!--/Name-->");
|
||||||
Console.WriteLine($"");
|
output.WriteLine($"");
|
||||||
Console.WriteLine($"- Source: <!--Source-->(LDM p{page})<!--/Source-->");
|
output.WriteLine($"- Source: <!--Source-->(LDM p{page})<!--/Source-->");
|
||||||
}
|
}
|
||||||
//else if (!keySpan.IdStyle.Contains("font-family:sans-serif; font-weight:normal; font-style:normal;") && CloseKeyValue())
|
//else if (!keySpan.IdStyle.Contains("font-family:sans-serif; font-weight:normal; font-style:normal;") && CloseKeyValue())
|
||||||
//{
|
//{
|
||||||
|
|
@ -516,7 +520,7 @@ namespace AideDeJeuCmd
|
||||||
{ // type / size / alignment
|
{ // type / size / alignment
|
||||||
// todo : découper type / size / alignment
|
// todo : découper type / size / alignment
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine($"- <!--Type-->{keySpan.Text}<!--/Alignment-->");
|
output.WriteLine($"- <!--Type-->{keySpan.Text}<!--/Alignment-->");
|
||||||
}
|
}
|
||||||
else if (keySpan.Style.Contains("rgba(121,27,16,1)"))
|
else if (keySpan.Style.Contains("rgba(121,27,16,1)"))
|
||||||
{ // key / ...
|
{ // key / ...
|
||||||
|
|
@ -526,9 +530,9 @@ namespace AideDeJeuCmd
|
||||||
tag = KeyTags[keySpan.Text.Trim()];
|
tag = KeyTags[keySpan.Text.Trim()];
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Blue;
|
Console.ForegroundColor = ConsoleColor.Blue;
|
||||||
Console.Write($"- **{keySpan.Text.Trim()}**");
|
output.Write($"- **{keySpan.Text.Trim()}**");
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine($" <!--{tag}-->{value}<!--/{tag}-->");
|
output.WriteLine($" <!--{tag}-->{value}<!--/{tag}-->");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -545,40 +549,51 @@ namespace AideDeJeuCmd
|
||||||
abilities += keySpan.Text;
|
abilities += keySpan.Text;
|
||||||
if(abilities.Count(c => c == '(') == 6)
|
if(abilities.Count(c => c == '(') == 6)
|
||||||
{
|
{
|
||||||
Console.WriteLine("|FOR|DEX|CON|INT|SAG|CHA|\n|---|---|---|---|---|---|");
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine("|" + abilities.Replace(") ",")").Replace(")",")|"));
|
output.WriteLine("\n|FOR|DEX|CON|INT|SAG|CHA|\n|---|---|---|---|---|---|");
|
||||||
|
output.WriteLine("|" + abilities.Replace(") ",")").Replace(")",")|") + "\n");
|
||||||
abilities = null;
|
abilities = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.Write($"{keySpan.Text}");
|
output.Write($"{keySpan.Text}");
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine($" {value}");
|
output.WriteLine($" {value}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(keySpan.Style.Contains("font-size:14px;vertical-align:baseline;color:rgba(137,23,26,1);"))
|
||||||
|
{ // actions / réactions
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
output.Write($"\n## {keySpan.Text}\n");
|
||||||
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
output.WriteLine($" {value}");
|
||||||
|
}
|
||||||
else if (keySpan.Style.Contains("color:rgba(203,0,0,1)"))
|
else if (keySpan.Style.Contains("color:rgba(203,0,0,1)"))
|
||||||
{ // bloodmark
|
{ // bloodmark
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
output.Write($"{keySpan.Text}");
|
||||||
|
output.WriteLine($" {value}");
|
||||||
}
|
}
|
||||||
else if (keySpan.Style.Contains("font-size:16px;vertical-align:baseline;color:rgba(255,207,52,1);"))
|
else if (keySpan.Style.Contains("font-size:16px;vertical-align:baseline;color:rgba(255,207,52,1);"))
|
||||||
{ // page
|
{ // page
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
output.Write($"{keySpan.Text}");
|
||||||
|
output.WriteLine($" {value}");
|
||||||
}
|
}
|
||||||
else if (keySpan.IdStyle.Contains("font-family:sans-serif; font-weight:normal; font-style:normal;"))
|
else if (keySpan.IdStyle.Contains("font-family:sans-serif; font-weight:normal; font-style:normal;"))
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.Write($"{keySpan.Text}");
|
output.Write($"{keySpan.Text}");
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine($" {value}");
|
output.WriteLine($" {value}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.Write($"{keySpan.Text}");
|
output.Write($"{keySpan.Text}");
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
output.WriteLine($" {value}");
|
||||||
Console.WriteLine($" {value}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue