From b6a48565c210c356e0ce2e5902ced0d9c8bc1bdb Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Sat, 21 Jul 2018 09:49:16 +0200 Subject: [PATCH] =?UTF-8?q?Properties=20g=C3=A9r=C3=A9es=20au=20niveau=20v?= =?UTF-8?q?iewer=20markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AideDeJeu/MarkdownView/MarkdownView.cs | 68 ++++++++-------- .../AideDeJeu/Models/Conditions/Generic.cs | 81 ++++++------------- 2 files changed, 60 insertions(+), 89 deletions(-) diff --git a/AideDeJeu/AideDeJeu/MarkdownView/MarkdownView.cs b/AideDeJeu/AideDeJeu/MarkdownView/MarkdownView.cs index 99629596..a785152e 100644 --- a/AideDeJeu/AideDeJeu/MarkdownView/MarkdownView.cs +++ b/AideDeJeu/AideDeJeu/MarkdownView/MarkdownView.cs @@ -218,42 +218,44 @@ Margin = new Thickness(listScope * this.Theme.Margin, 0, 0, 0), }; - View bullet; - - if (parent.IsOrdered) + if (parent.BulletType != '-') { - bullet = new Label - { - Text = $"{index}.", - FontSize = this.Theme.Paragraph.FontSize, - TextColor = this.Theme.Paragraph.ForegroundColor, - VerticalOptions = LayoutOptions.Start, - HorizontalOptions = LayoutOptions.End, - }; - } - else - { - bullet = new Label - { - Text = "●", - FontSize = this.Theme.Paragraph.FontSize, - TextColor = this.Theme.Paragraph.ForegroundColor, - VerticalOptions = LayoutOptions.Start, - HorizontalOptions = LayoutOptions.End, - }; - //bullet = new BoxView - //{ - // WidthRequest = 4, - // HeightRequest = 4, - // Margin = new Thickness(0, 6, 0, 0), - // BackgroundColor = this.Theme.Paragraph.ForegroundColor, - // VerticalOptions = LayoutOptions.Start, - // HorizontalOptions = LayoutOptions.Center, - //}; - } + View bullet; - horizontalStack.Children.Add(bullet); + if (parent.IsOrdered) + { + bullet = new Label + { + Text = $"{index}.", + FontSize = this.Theme.Paragraph.FontSize, + TextColor = this.Theme.Paragraph.ForegroundColor, + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.End, + }; + } + else + { + bullet = new Label + { + Text = "●", + FontSize = this.Theme.Paragraph.FontSize, + TextColor = this.Theme.Paragraph.ForegroundColor, + VerticalOptions = LayoutOptions.Start, + HorizontalOptions = LayoutOptions.End, + }; + //bullet = new BoxView + //{ + // WidthRequest = 4, + // HeightRequest = 4, + // Margin = new Thickness(0, 6, 0, 0), + // BackgroundColor = this.Theme.Paragraph.ForegroundColor, + // VerticalOptions = LayoutOptions.Start, + // HorizontalOptions = LayoutOptions.Center, + //}; + } + horizontalStack.Children.Add(bullet); + } horizontalStack.Children.Add(this.stack); initialStack.Children.Add(horizontalStack); diff --git a/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs b/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs index 8382e058..3242c44e 100644 --- a/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs +++ b/AideDeJeu/AideDeJeu/Models/Conditions/Generic.cs @@ -19,8 +19,8 @@ namespace AideDeJeuLib get { return - $"# {Name}\n\n" + - $"{AltName}\n\n" + + //$"# {Name}\n\n" + + //$"{AltName}\n\n" + Text; } } @@ -31,33 +31,17 @@ namespace AideDeJeuLib while (enumerator.Current != null) { var block = enumerator.Current; + if (block.IsNewItem()) + { + return; + } if (block is HeadingBlock) { var headingBlock = block as HeadingBlock; - if (headingBlock.HeaderChar == '#' && (headingBlock.Level == 1 || headingBlock.Level == 2)) + if (this.Name == null) { - if (this.Name == null) - { - this.Name = headingBlock.Inline.ToMarkdownString(); - } - else - { - this.Text += block.ToMarkdownString(); - } + this.Name = headingBlock.Inline.ToMarkdownString(); } - else - { - this.Text += block.ToMarkdownString(); - } - } - else if (block is ParagraphBlock) - { - if (block.IsNewItem()) - { - return; - } - //var paragraphBlock = block as ParagraphBlock; - //this.Text += paragraphBlock.ToMarkdownString() + "\n"; this.Text += block.ToMarkdownString(); } else if (block is ListBlock) @@ -65,35 +49,26 @@ namespace AideDeJeuLib var listBlock = block as ListBlock; if (listBlock.BulletType == '-') { - foreach (var inblock in listBlock) + var regex = new Regex("(?.*?): (?.*)"); + var str = block.ToMarkdownString(); + var properties = new List>>() { - var regex = new Regex("(?.*?): (?.*)"); - if (inblock is ListItemBlock) + new Tuple>("- AltName: ", (m, s) => { - var listItemBlock = inblock as ListItemBlock; - foreach (var ininblock in listItemBlock) - { - if (ininblock is ParagraphBlock) - { - var paragraphBlock = ininblock as ParagraphBlock; - var str = paragraphBlock.Inline.ToMarkdownString(); + this.Text += "- " + s; m.AltName = s; + }), + new Tuple>("", (m, s) => + { + this.Text += str; + }), + }; - var properties = new List>>() - { - new Tuple>("AltName: ", (m, s) => m.AltName = s), - }; - - foreach (var property in properties) - { - if (str.StartsWith(property.Item1)) - { - property.Item2.Invoke(this, str.Substring(property.Item1.Length)); - break; - } - } - - } - } + foreach (var property in properties) + { + if (str.StartsWith(property.Item1)) + { + property.Item2.Invoke(this, str.Substring(property.Item1.Length)); + break; } } } @@ -102,12 +77,6 @@ namespace AideDeJeuLib this.Text += block.ToMarkdownString(); } } - else if (block is Markdig.Extensions.Tables.Table) - { - this.Text += block.ToMarkdownString(); - //var tableBlock = block as Markdig.Extensions.Tables.Table; - //this.Text += "\n\n" + tableBlock.ToMarkdownString() + "\n\n"; - } else { this.Text += block.ToMarkdownString();