From 6b35d38513e41f946d20c4a403e0fdd0b156a1a5 Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Tue, 26 Jun 2018 22:58:06 +0200 Subject: [PATCH] Correction parsing rituel/ritual --- AideDeJeu/AideDeJeu/Models/Spells/Spell.cs | 2 +- .../AideDeJeu/Tools/MarkdownExtensions.cs | 110 +++++++++--------- .../AideDeJeu/ViewModels/FilterViewModel.cs | 2 +- Data/spells_hd.md | 2 +- 4 files changed, 61 insertions(+), 55 deletions(-) diff --git a/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs b/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs index 695ab415..ac5a0442 100644 --- a/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs +++ b/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs @@ -36,7 +36,7 @@ namespace AideDeJeuLib.Spells { System.Diagnostics.Debug.WriteLine(value); //re = new Regex("level (?\\d) - (?.*?)\\w?(?\\(ritual\\))?"); - re = new Regex("(?\\d) - (?.*)\\w?(?\\(ritual\\))?"); + re = new Regex("^(?\\d) - (?.*?)\\s?(?\\(ritual\\))?$"); match = re.Match(value); this.Type = match.Groups["type"].Value; this.Level = match.Groups["level"].Value; diff --git a/AideDeJeu/AideDeJeu/Tools/MarkdownExtensions.cs b/AideDeJeu/AideDeJeu/Tools/MarkdownExtensions.cs index dc6f54b5..4da50531 100644 --- a/AideDeJeu/AideDeJeu/Tools/MarkdownExtensions.cs +++ b/AideDeJeu/AideDeJeu/Tools/MarkdownExtensions.cs @@ -478,61 +478,67 @@ namespace AideDeJeu.Tools var str = string.Empty; foreach (var inline in inlines) { - //Debug.WriteLine(inline.GetType()); - string add = string.Empty; - if (inline is Markdig.Syntax.Inlines.LineBreakInline) - { - add = "\n"; - } - else if (inline is Markdig.Syntax.Inlines.LiteralInline) - { - var literalInline = inline as Markdig.Syntax.Inlines.LiteralInline; - add = literalInline.Content.ToString(); - } - else if (inline is Markdig.Syntax.Inlines.EmphasisInline) - { - var emphasisInline = inline as Markdig.Syntax.Inlines.EmphasisInline; - var delimiterChar = emphasisInline.DelimiterChar.ToString(); - if (emphasisInline.IsDouble) - { - delimiterChar += delimiterChar; - } - add = delimiterChar + emphasisInline.ToMarkdownString() + delimiterChar; - } - else if (inline is Markdig.Syntax.Inlines.LinkInline) - { - var linkInline = inline as Markdig.Syntax.Inlines.LinkInline; - add = string.Empty; - if (linkInline.IsImage) - { - add = "!"; - } - var label = linkInline.ToMarkdownString(); - var url = linkInline.Url; - var title = linkInline.Title; - if (!string.IsNullOrEmpty(title)) - { - add += string.Format($"[{label}]({url} \"{title}\")"); - } - else - { - add += string.Format($"[{label}]({url})"); - } - } - else if (inline is Markdig.Syntax.Inlines.ContainerInline) - { - var containerInline = inline as Markdig.Syntax.Inlines.ContainerInline; - add = containerInline.ToMarkdownString(); - } - else - { - add = inline.ToString(); - } - //Debug.WriteLine(add); - str += add; + str += inline.ToMarkdownString(); } return str; } + + public static string ToMarkdownString(this Markdig.Syntax.Inlines.Inline inline) + { + //Debug.WriteLine(inline.GetType()); + string add = string.Empty; + if (inline is Markdig.Syntax.Inlines.LineBreakInline) + { + add = "\n"; + } + else if (inline is Markdig.Syntax.Inlines.LiteralInline) + { + var literalInline = inline as Markdig.Syntax.Inlines.LiteralInline; + add = literalInline.Content.ToString(); + } + else if (inline is Markdig.Syntax.Inlines.EmphasisInline) + { + var emphasisInline = inline as Markdig.Syntax.Inlines.EmphasisInline; + var delimiterChar = emphasisInline.DelimiterChar.ToString(); + if (emphasisInline.IsDouble) + { + delimiterChar += delimiterChar; + } + add = delimiterChar + emphasisInline.ToMarkdownString() + delimiterChar; + } + else if (inline is Markdig.Syntax.Inlines.LinkInline) + { + var linkInline = inline as Markdig.Syntax.Inlines.LinkInline; + add = string.Empty; + if (linkInline.IsImage) + { + add = "!"; + } + var label = linkInline.ToMarkdownString(); + var url = linkInline.Url; + var title = linkInline.Title; + if (!string.IsNullOrEmpty(title)) + { + add += string.Format($"[{label}]({url} \"{title}\")"); + } + else + { + add += string.Format($"[{label}]({url})"); + } + } + else if (inline is Markdig.Syntax.Inlines.ContainerInline) + { + var containerInline = inline as Markdig.Syntax.Inlines.ContainerInline; + add = containerInline.ToMarkdownString(); + } + else + { + add = inline.ToString(); + } + //Debug.WriteLine(add); + return add; + } + public static string ToMarkdownString(this Markdig.Syntax.ParagraphBlock paragraphBlock) { var str = string.Empty; diff --git a/AideDeJeu/AideDeJeu/ViewModels/FilterViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/FilterViewModel.cs index 01efc17e..45e3ba93 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/FilterViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/FilterViewModel.cs @@ -132,7 +132,7 @@ namespace AideDeJeu.ViewModels spell.Type.ToLower().Contains(ecole.ToLower()) && spell.Source.Contains(source) && spell.Source.Contains(classe) && - spell.Type.Contains(rituel) && + spell.Rituel.Contains(rituel) && Helpers.RemoveDiacritics(spell.NamePHB).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower()); }).OrderBy(spell => spell.NamePHB) .AsEnumerable(); diff --git a/Data/spells_hd.md b/Data/spells_hd.md index d54ae2c5..e10ec2c7 100644 --- a/Data/spells_hd.md +++ b/Data/spells_hd.md @@ -1499,7 +1499,7 @@ Si vous lancez ce sort à deux reprises ou plus avant un long repos, il y a 25 % # Communion avec la nature -- NameVO: [Commune](spells_vo.md#commune) with Nature +- NameVO: [Commune with Nature](spells_vo.md#commune-with-nature) - CastingTime: 1 minute - Components: V, S - Duration: instantanée