mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Test
This commit is contained in:
parent
5a84305bd6
commit
9e296c3700
2 changed files with 232 additions and 198 deletions
|
|
@ -15,6 +15,7 @@ using System.Runtime.Serialization.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
using YamlDotNet.Serialization.NamingConventions;
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
|
|
@ -358,6 +359,7 @@ namespace AideDeJeuCmd
|
||||||
Console.WriteLine("p : test pdf");
|
Console.WriteLine("p : test pdf");
|
||||||
Console.WriteLine("h : extract html");
|
Console.WriteLine("h : extract html");
|
||||||
Console.WriteLine("y : extract yaml");
|
Console.WriteLine("y : extract yaml");
|
||||||
|
Console.WriteLine("m : convert maps");
|
||||||
Console.WriteLine("q : quitter");
|
Console.WriteLine("q : quitter");
|
||||||
var key = Console.ReadKey(true);
|
var key = Console.ReadKey(true);
|
||||||
switch (key.KeyChar)
|
switch (key.KeyChar)
|
||||||
|
|
@ -387,12 +389,43 @@ namespace AideDeJeuCmd
|
||||||
await ExtractYamlAsync();
|
await ExtractYamlAsync();
|
||||||
Console.WriteLine("/ extract yaml");
|
Console.WriteLine("/ extract yaml");
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
Console.WriteLine("> convert maps");
|
||||||
|
await ConvertMapsAsync();
|
||||||
|
Console.WriteLine("/ convert maps");
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async Task ConvertMapsAsync()
|
||||||
|
{
|
||||||
|
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
|
||||||
|
document.Load(@"..\..\..\..\..\Docs\Osgild\ferrance.map.html");
|
||||||
|
var svg = new XmlDocument();
|
||||||
|
var svgElt = svg.CreateElement("svg", "http://www.w3.org/2000/svg");
|
||||||
|
svg.AppendChild(svgElt);
|
||||||
|
var areas = document.DocumentNode.SelectNodes("//area");
|
||||||
|
foreach(var area in areas)
|
||||||
|
{
|
||||||
|
var coords = area.GetAttributeValue("coords", "");
|
||||||
|
var coordsSplit = coords.Split(",");
|
||||||
|
|
||||||
|
var a = svg.CreateElement("a");
|
||||||
|
a.SetAttribute("href", area.GetAttributeValue("href", ""));
|
||||||
|
a.SetAttribute("target", area.GetAttributeValue("target", ""));
|
||||||
|
var rect = svg.CreateElement("rect");
|
||||||
|
rect.SetAttribute("x", coordsSplit[0]);
|
||||||
|
var title = svg.CreateElement("title");
|
||||||
|
title.InnerText = area.GetAttributeValue("alt", "");
|
||||||
|
rect.AppendChild(title);
|
||||||
|
a.AppendChild(rect);
|
||||||
|
svgElt.AppendChild(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async Task ExtractYamlAsync()
|
static async Task ExtractYamlAsync()
|
||||||
{
|
{
|
||||||
var tomeOfBeasts = await LoadStringAsync(@"..\..\..\..\..\Data\tome_of_beasts.md");
|
var tomeOfBeasts = await LoadStringAsync(@"..\..\..\..\..\Data\tome_of_beasts.md");
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue