mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Parsing
This commit is contained in:
		
							parent
							
								
									dbefb187c3
								
							
						
					
					
						commit
						5636695290
					
				
					 1 changed files with 24 additions and 21 deletions
				
			
		|  | @ -380,13 +380,16 @@ namespace AideDeJeuCmd | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         static async Task ExtractHtmlAsync() |         static async Task ExtractHtmlAsync() | ||||||
|  |         { | ||||||
|  |             using (var output = new StreamWriter(@"..\..\..\..\..\Ignore\tome_of_beasts.md", false, Encoding.UTF8)) | ||||||
|             { |             { | ||||||
|                 for (int i = 10; i <= 428; 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), Console.Out); |                     parser.OutputMarkdown(parser.Parse(doc), output, Console.Error); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -479,7 +482,7 @@ namespace AideDeJeuCmd | ||||||
|                 return fullText; |                 return fullText; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             public void OutputMarkdown(FullText fullText, TextWriter output) |             public void OutputMarkdown(FullText fullText, TextWriter output, TextWriter error) | ||||||
|             { |             { | ||||||
|                 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; | ||||||
|  | @ -503,32 +506,32 @@ 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; |                         Console.ForegroundColor = ConsoleColor.DarkGray; | ||||||
|                         output.Write($"{keySpan.Text}"); |                         error.Write($"{keySpan.Text}"); | ||||||
|                         output.WriteLine($" {value}"); |                         error.WriteLine($" {value}"); | ||||||
| 
 | 
 | ||||||
|                         if(keySpan.Style.Contains("font-size:48px;vertical-align:baseline;color:rgba(0,0,0,1);")) |                         if(keySpan.Style.Contains("font-size:48px;vertical-align:baseline;color:rgba(0,0,0,1);")) | ||||||
|                         {   // titre de page |                         {   // titre de page | ||||||
|                             Console.ForegroundColor = ConsoleColor.Red; |                             Console.ForegroundColor = ConsoleColor.Red; | ||||||
|                             output.Write($"{keySpan.Text}"); |                             error.Write($"{keySpan.Text}"); | ||||||
|                             output.WriteLine($" {value}"); |                             error.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; |                             Console.ForegroundColor = ConsoleColor.Red; | ||||||
|                             output.Write($"{keySpan.Text}"); |                             error.Write($"{keySpan.Text}"); | ||||||
|                             output.WriteLine($" {value}"); |                             error.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; |                             Console.ForegroundColor = ConsoleColor.Red; | ||||||
|                             output.Write($"{keySpan.Text}"); |                             error.Write($"{keySpan.Text}"); | ||||||
|                             output.WriteLine($" {value}"); |                             error.WriteLine($" {value}"); | ||||||
|                         } |                         } | ||||||
|                         else if (keySpan.Style.Contains("font-size:8px;vertical-align:baseline;color:rgba(0,0,0,1)") && keySpan.IdStyle.Contains("font-family:serif; font-weight:normal; font-style:normal;")) |                         else if (keySpan.Style.Contains("font-size:8px;vertical-align:baseline;color:rgba(0,0,0,1)") && keySpan.IdStyle.Contains("font-family:serif; font-weight:normal; font-style:normal;")) | ||||||
|                         {   // encadré |                         {   // encadré | ||||||
|                             Console.ForegroundColor = ConsoleColor.Red; |                             Console.ForegroundColor = ConsoleColor.Red; | ||||||
|                             output.Write($"{keySpan.Text}"); |                             error.Write($"{keySpan.Text}"); | ||||||
|                             output.WriteLine($" {value}"); |                             error.WriteLine($" {value}"); | ||||||
|                         } |                         } | ||||||
|                         else if (keySpan.Style.Contains("font-size:11px;vertical-align:baseline;color:rgba(255,207,52,1);")) |                         else if (keySpan.Style.Contains("font-size:11px;vertical-align:baseline;color:rgba(255,207,52,1);")) | ||||||
|                         {   // nom |                         {   // nom | ||||||
|  | @ -560,7 +563,7 @@ namespace AideDeJeuCmd | ||||||
|                             else |                             else | ||||||
|                             { |                             { | ||||||
|                                 Console.ForegroundColor = ConsoleColor.Red; |                                 Console.ForegroundColor = ConsoleColor.Red; | ||||||
|                                 output.WriteLine($"ABILITIES"); |                                 error.WriteLine($"ABILITIES"); | ||||||
|                                 if (abilities == null) |                                 if (abilities == null) | ||||||
|                                 { |                                 { | ||||||
|                                     abilities = ""; |                                     abilities = ""; | ||||||
|  | @ -602,12 +605,12 @@ namespace AideDeJeuCmd | ||||||
|                         else |                         else | ||||||
|                         { |                         { | ||||||
|                             Console.ForegroundColor = ConsoleColor.Red; |                             Console.ForegroundColor = ConsoleColor.Red; | ||||||
|                             output.Write($"{keySpan.Text}"); |                             error.Write($"{keySpan.Text}"); | ||||||
|                             output.WriteLine($" {value}"); |                             error.WriteLine($" {value}"); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 Console.ReadKey(); |                 //Console.ReadKey(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             void StripLine() |             void StripLine() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez