From 9dda5f0eb2260f4a69899216475fc86c08dc2239 Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Wed, 15 Aug 2018 10:29:11 +0200 Subject: [PATCH] AltName --- .../AideDeJeu/Models/Conditions/Generic.cs | 51 ++++++++++++------- AideDeJeu/AideDeJeu/Models/Item.cs | 6 +++ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs b/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs index b1adf900..8683ca35 100644 --- a/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs +++ b/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs @@ -42,28 +42,43 @@ namespace AideDeJeuLib var listBlock = block as ListBlock; if (listBlock.BulletType == '-') { - var regex = new Regex("(?.*?): (?.*)"); - var str = block.ToMarkdownString(); - var properties = new List>>() - { - new Tuple>("- AltName: ", (m, s) => - { - this.Text += "- " + s; m.AltName = s; - }), - new Tuple>("", (m, s) => - { - this.Text += str; - }), - }; - - foreach (var property in properties) + foreach (var inblock in listBlock) { - if (str.StartsWith(property.Item1)) + if (inblock is Markdig.Syntax.ListItemBlock) { - property.Item2.Invoke(this, str.Substring(property.Item1.Length)); - break; + var listItemBlock = inblock as Markdig.Syntax.ListItemBlock; + foreach (var ininblock in listItemBlock) + { + if (ininblock is Markdig.Syntax.ParagraphBlock) + { + var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock; + var str = paragraphBlock.ToMarkdownString(); + var regex = new Regex("(?.*?): (?.*)"); + var properties = new List>>() + { + new Tuple>("AltName: ", (m, s) => + { + this.Text += "- " + s; m.AltName = s; + }), + new Tuple>("", (m, s) => + { + this.Text += str; + }), + }; + + foreach (var property in properties) + { + if (str.StartsWith(property.Item1)) + { + property.Item2.Invoke(this, str.Substring(property.Item1.Length)); + break; + } + } + } + } } } + this.Text += "\n"; } else { diff --git a/AideDeJeu/AideDeJeu/Models/Item.cs b/AideDeJeu/AideDeJeu/Models/Item.cs index 2aa1d162..d0a60db8 100644 --- a/AideDeJeu/AideDeJeu/Models/Item.cs +++ b/AideDeJeu/AideDeJeu/Models/Item.cs @@ -21,6 +21,12 @@ namespace AideDeJeuLib } else { + regex = new Regex("(?.*?)( \\(SRD p\\d*\\))"); + match = regex.Match(AltName ?? string.Empty); + if (!string.IsNullOrEmpty(match.Groups["text"].Value)) + { + return match.Groups["text"].Value; + } return AltName ?? string.Empty; } }