mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2026-05-15 17:10:18 +00:00
Finalisation races
This commit is contained in:
parent
5aa3b46ce0
commit
f84b1675b1
17 changed files with 454 additions and 185 deletions
67
AideDeJeu/AideDeJeu/Models/LinkItem.cs
Normal file
67
AideDeJeu/AideDeJeu/Models/LinkItem.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using AideDeJeu.Tools;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class LinkItem : Item
|
||||
{
|
||||
public string Link { get; set; }
|
||||
public string NameLink
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Name != null && Link != null)
|
||||
{
|
||||
return $"[{Name}]({Link})";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
var regex = new Regex("\\[(?<name>.*?)\\]\\((?<link>.*?)\\)");
|
||||
var match = regex.Match(value);
|
||||
Name = match.Groups["name"].Value;
|
||||
Link = match.Groups["link"].Value;
|
||||
}
|
||||
}
|
||||
public override string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"# {NameLink}\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
enumerator.MoveNext();
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
var block = enumerator.Current;
|
||||
if (block is HeadingBlock)
|
||||
{
|
||||
var headingBlock = block as HeadingBlock;
|
||||
if (headingBlock.HeaderChar == '#' && (headingBlock.Level == 1 || headingBlock.Level == 2))
|
||||
{
|
||||
if (this.NameLink == null)
|
||||
{
|
||||
this.NameLink = headingBlock.Inline.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (block is ParagraphBlock)
|
||||
{
|
||||
if (block.IsNewItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,14 @@ namespace AideDeJeu.ViewModels
|
|||
SetProperty(ref _SelectedItem, value);
|
||||
if (_SelectedItem != null)
|
||||
{
|
||||
Main.Navigator.GotoItemDetailPageAsync(_SelectedItem);
|
||||
if (_SelectedItem is LinkItem)
|
||||
{
|
||||
Main.NavigateToLink("/" + (_SelectedItem as LinkItem).Link);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.Navigator.GotoItemDetailPageAsync(_SelectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue