mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
Fixed UiMarkdownParser not parsing formatting in headings and blockquotes
This commit is contained in:
parent
af0aee6c40
commit
6a271af017
2 changed files with 19 additions and 15 deletions
|
@ -29,6 +29,7 @@ Fixes
|
||||||
- Fixed parents of elements that prevent spill not being notified properly
|
- Fixed parents of elements that prevent spill not being notified properly
|
||||||
- Fixed paragraphs sometimes not updating their position properly when hidden because they're empty
|
- Fixed paragraphs sometimes not updating their position properly when hidden because they're empty
|
||||||
- Fixed panels sometimes not drawing children that came into view when their positions changed unexpectedly
|
- Fixed panels sometimes not drawing children that came into view when their positions changed unexpectedly
|
||||||
|
- Fixed UiMarkdownParser not parsing formatting in headings and blockquotes
|
||||||
|
|
||||||
### MLEM.Data
|
### MLEM.Data
|
||||||
Improvements
|
Improvements
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace MLEM.Ui.Parsers {
|
||||||
|
|
||||||
// quotes
|
// quotes
|
||||||
if (line.StartsWith(">")) {
|
if (line.StartsWith(">")) {
|
||||||
yield return (ElementType.Blockquote, new Paragraph(Anchor.AutoLeft, 1, line.Substring(1).Trim()));
|
yield return (ElementType.Blockquote, new Paragraph(Anchor.AutoLeft, 1, this.ParseParagraph(line.Substring(1).Trim())));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ namespace MLEM.Ui.Parsers {
|
||||||
for (var h = 6; h >= 1; h--) {
|
for (var h = 6; h >= 1; h--) {
|
||||||
if (line.StartsWith(new string('#', h))) {
|
if (line.StartsWith(new string('#', h))) {
|
||||||
var type = UiMarkdownParser.ElementTypes[Array.IndexOf(UiMarkdownParser.ElementTypes, ElementType.Header1) + h - 1];
|
var type = UiMarkdownParser.ElementTypes[Array.IndexOf(UiMarkdownParser.ElementTypes, ElementType.Header1) + h - 1];
|
||||||
yield return (type, new Paragraph(Anchor.AutoLeft, 1, line.Substring(h).Trim()));
|
yield return (type, new Paragraph(Anchor.AutoLeft, 1, this.ParseParagraph(line.Substring(h).Trim())));
|
||||||
parsedHeader = true;
|
parsedHeader = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,11 @@ namespace MLEM.Ui.Parsers {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// parse everything else as a paragraph (with formatting)
|
// parse everything else as a paragraph (with formatting)
|
||||||
var par = line;
|
yield return (ElementType.Paragraph, new Paragraph(Anchor.AutoLeft, 1, this.ParseParagraph(line)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ParseParagraph(string par) {
|
||||||
// replace links
|
// replace links
|
||||||
par = Regex.Replace(par, @"<([^>]+)>", "<l $1>$1</l>");
|
par = Regex.Replace(par, @"<([^>]+)>", "<l $1>$1</l>");
|
||||||
par = Regex.Replace(par, @"\[([^\]]+)\]\(([^)]+)\)", "<l $2>$1</l>");
|
par = Regex.Replace(par, @"\[([^\]]+)\]\(([^)]+)\)", "<l $2>$1</l>");
|
||||||
|
@ -219,8 +223,7 @@ namespace MLEM.Ui.Parsers {
|
||||||
par = Regex.Replace(par, @"~~([^~]+)~~", "<st>$1</st>");
|
par = Regex.Replace(par, @"~~([^~]+)~~", "<st>$1</st>");
|
||||||
// replace inline code with custom code font
|
// replace inline code with custom code font
|
||||||
par = Regex.Replace(par, @"`([^`]+)`", $"<f {this.CodeFont}>$1</f>");
|
par = Regex.Replace(par, @"`([^`]+)`", $"<f {this.CodeFont}>$1</f>");
|
||||||
yield return (ElementType.Paragraph, new Paragraph(Anchor.AutoLeft, 1, par));
|
return par;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue