Skip to content

Commit

Permalink
fix: Single underline does work correctly for italics.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xc3u committed Aug 24, 2024
1 parent 78699b4 commit 59ae20f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.80" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.80" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.8" />
<PackageReference Include="SkiaSharp.Views.Maui.Core" Version="2.88.8" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.80" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.80" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 9 additions & 1 deletion src/Indiko.Maui.Controls.Markdown/MarkdownView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private FormattedString CreateFormattedString(string line, Color textColor)
{
var formattedString = new FormattedString();

var parts = Regex.Split(line, @"(\*\*.*?\*\*|__.*?__|_.*?_|`.*?`|\[.*?\]\(.*?\))");
var parts = Regex.Split(line, @"(\*\*.*?\*\*|__.*?__|_.*?_|`.*?`|\[.*?\]\(.*?\)|\*.*?\*)");

foreach (var part in parts)
{
Expand Down Expand Up @@ -726,6 +726,13 @@ private FormattedString CreateFormattedString(string line, Color textColor)
span.TextColor = textColor;
span.FontFamily = TextFontFace;
}
else if (part.StartsWith('*') && part.EndsWith('*'))
{
span.Text = part.Trim('*', ' ');
span.FontAttributes = FontAttributes.Italic;
span.TextColor = textColor;
span.FontFamily = TextFontFace;
}
else if (part.StartsWith('[') && part.Contains("](")) // Link detection
{
var linkText = part[1..part.IndexOf(']')];
Expand Down Expand Up @@ -755,6 +762,7 @@ private FormattedString CreateFormattedString(string line, Color textColor)
return formattedString;
}


private void AddBulletPointToGrid(Grid grid, int gridRow)
{
string bulletPointSign = "-";
Expand Down

0 comments on commit 59ae20f

Please sign in to comment.