Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
Expand All @@ -24,6 +24,8 @@ internal class BBCodeParser
private const string TagSize = "size";
private const string TagUnderline = "u";
private const string TagUrl = "url";
private const string TagList = "list";
private const string TagListItem = "*";

class ParseContext
{
Expand All @@ -38,6 +40,8 @@ public ParseContext(Span parent)
public Brush Foreground { get; set; }
public TextDecorationCollection TextDecorations { get; set; }
public string NavigateUri { get; set; }
public bool IsList { get; set; }
public bool IsListItem { get; set; }

/// <summary>
/// Creates a run reflecting the current context settings.
Expand Down Expand Up @@ -143,6 +147,15 @@ private void ParseTag(string tag, bool start, ParseContext context)
context.NavigateUri = null;
}
}
else if (tag == TagList) {
context.IsList = start;
if (!start) {
context.IsListItem = false;
}
}
else if (tag == TagListItem) {
context.IsListItem = true;
}
}

private void Parse(Span span)
Expand Down Expand Up @@ -185,6 +198,20 @@ private void Parse(Span span)
parent = link;
span.Inlines.Add(parent);
}

var text = token.Value;
if (context.IsList && context.IsListItem)
{
text = "\u25CF" + "text";
}

var run = context.CreateRun(text);
parent.Inlines.Add(run);

if (context.IsList)
{
parent.Inlines.Add(new LineBreak());
}
var run = context.CreateRun(token.Value);
parent.Inlines.Add(run);
}
Expand Down