Skip to content

Commit

Permalink
Merge pull request #91 from whistyun/repo0.10-dev
Browse files Browse the repository at this point in the history
1. apply a monospace font for codeblock elements. refs #90
2. modify list parsing: mistake treating bold syntax as horizontal line. refs whistyun/MdXaml#52
  • Loading branch information
whistyun authored Jan 25, 2023
2 parents 1d21d82 + b893916 commit 9620488
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
<Authors>whistyun</Authors>
<Copyright>Copyright (c) 2021 whistyun</Copyright>
<PackageProjectUrl>https://github.com/whistyun/Markdown.Avalonia</PackageProjectUrl>
<PackageReadmeFile>Markdown.Avalonia.SyntaxHigh.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Company />
</PropertyGroup>

<ItemGroup>
<None Include="..\pack_readme\Markdown.Avalonia.SyntaxHigh.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="$(AvaloniaVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
>
<Style Selector="avedit|TextEditor">
<Setter Property="SyntaxHighlighting" Value="{mde:SyntaxHighlightWrapper ThemeForegroundColor}"/>
<Setter Property="FontFamily" Value="menlo,monaco,consolas,droid sans mono,inconsolata,courier new,monospace,dejavu sans mono"/>
<Setter Property="VerticalScrollBarVisibility" Value="Disabled"/>
</Style>
</Styles>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
>
<Style Selector="avedit|TextEditor">
<Setter Property="SyntaxHighlighting" Value="{mde:SyntaxHighlightWrapper SystemBaseHighColor}"/>
<Setter Property="FontFamily" Value="menlo,monaco,consolas,droid sans mono,inconsolata,courier new,monospace,dejavu sans mono"/>
<Setter Property="VerticalScrollBarVisibility" Value="Disabled"/>
</Style>
</Styles>
5 changes: 5 additions & 0 deletions Markdown.Avalonia.Tight/Markdown.Avalonia.Tight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
<Copyright>Copyright (c) 2010 Bevan Arps, 2020 whistyun</Copyright>
<PackageProjectUrl>https://github.com/whistyun/Markdown.Avalonia</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>Markdown.Avalonia.Tight.md</PackageReadmeFile>
<PackageTags>Markdown Avalonia Avaloniaui</PackageTags>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<ItemGroup>
<None Include="..\pack_readme\Markdown.Avalonia.Tight.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Markdown.Avalonia.Tight/Markdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ private Rule RuleEvaluator(Match match)
private static readonly string _wholeList = string.Format(@"
(?<whltxt> # whole list
(?<mkr_i> # list marker with indent
(?![ ]{{0,3}}(?<hrm>[-=*_])([ ]{{0,2}}\k<hrm>){{2,}})
(?![ ]{{0,3}}(?<hrm>[-=*_])([ ]{{0,2}}\k<hrm>){{2,}}[ ]*\n)
(?<idt>[ ]{{0,{2}}})
(?<mkr>{0}) # first list item marker
[ ]+
Expand All @@ -729,7 +729,7 @@ [ ]*
)
)", _firstListMaker, _subseqListMaker, _listDepth - 1);

private static readonly Regex _startNoIndentRule = new Regex(@"\A[ ]{0,2}(?<hrm>[-=*_])([ ]{0,2}\k<hrm>){2,}",
private static readonly Regex _startNoIndentRule = new Regex(@"\A[ ]{0,2}(?<hrm>[-=*_])([ ]{0,2}\k<hrm>){2,}[ ]*$",
RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);

private static readonly Regex _startNoIndentSublistMarker = new Regex(@"\A" + _subseqListMaker, RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
</Style>
<Style Selector="TextBlock.CodeBlock">
<Style.Setters>
<Setter Property="FontFamily" Value="menlo,monaco,consolas,droid sans mono,inconsolata,courier new,monospace,dejavu sans mono"/>
<Setter Property="Foreground" Value="{mde:DivideColor Blue, ThemeForegroundColor, 0.45}"/>
</Style.Setters>
</Style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
</Style>
<Style Selector="TextBlock.CodeBlock">
<Style.Setters>
<Setter Property="FontFamily" Value="menlo,monaco,consolas,droid sans mono,inconsolata,courier new,monospace,dejavu sans mono"/>
<Setter Property="Foreground" Value="{mde:DivideColor Blue, SystemBaseHighColor, 0.45}"/>
</Style.Setters>
</Style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@
</Style>
<Style Selector="TextBlock.CodeBlock">
<Style.Setters>
<Setter Property="FontFamily" Value="menlo,monaco,consolas,droid sans mono,inconsolata,courier new,monospace,dejavu sans mono"/>
<Setter Property="FontSize" Value="11.9"/>
<Setter Property="Foreground" Value="DarkBlue"/>
<Setter Property="Foreground" Value="DarkBlue"/>
</Style.Setters>
</Style>
<Style Selector="Border.NoContainer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</Style>
<Style Selector="TextBlock.CodeBlock">
<Style.Setters>
<Setter Property="FontFamily" Value="menlo,monaco,consolas,droid sans mono,inconsolata,courier new,monospace,dejavu sans mono"/>
<Setter Property="Foreground" Value="DarkBlue"/>
</Style.Setters>
</Style>
Expand Down
2 changes: 1 addition & 1 deletion Markdown.Avalonia.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</PropertyGroup>

<PropertyGroup>
<PackageVersion>0.10.12</PackageVersion>
<PackageVersion>0.10.13</PackageVersion>
</PropertyGroup>

</Project>
Expand Down
6 changes: 6 additions & 0 deletions Markdown.Avalonia/Markdown.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<Copyright>Copyright (c) 2010 Bevan Arps, 2020 whistyun</Copyright>
<PackageProjectUrl>https://github.com/whistyun/Markdown.Avalonia</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>Markdown.Avalonia.md</PackageReadmeFile>
<PackageTags>Markdown Avalonia Avaloniaui</PackageTags>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -20,6 +21,11 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSymbols>false</IncludeSymbols>
</PropertyGroup>

<ItemGroup>
<None Include="..\pack_readme\Markdown.Avalonia.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Markdown.Avalonia.Tight\Markdown.Avalonia.Tight.csproj" />
<ProjectReference Include="..\Markdown.Avalonia.SyntaxHigh\Markdown.Avalonia.SyntaxHigh.csproj" />
Expand Down
1 change: 1 addition & 0 deletions pack_readme/Markdown.Avalonia.SyntaxHigh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This package add syntax highlighint feature to Markdown.Avalonia.Tight
29 changes: 29 additions & 0 deletions pack_readme/Markdown.Avalonia.Tight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Markdown.Avalonia render Markdown with avalonia ui. It transform markdown to controls (ex: Border, Grid, TextBlock).

There is no syntax highlighting for code blocks in this package. If you want syntax highlighting, use [Markdown.Avalonia](https://www.nuget.org/packages/Markdown.Avalonia) instead.

**How to use**

Markdown.Avalonia supports three methods to render markdown.

1. [Load .md from AvaloniaResource](https://github.com/whistyun/Markdown.Avalonia/wiki/How-to-use#Load-.md-from-AvaloniaResource)
```xml
<md:MarkdownScrollViewer
Source="avares://YourAssemblyName/MdTxt/Test.md"/>
```
2. [Write markdown in xaml](https://github.com/whistyun/Markdown.Avalonia/wiki/How-to-use#Write-markdown-in-xaml)
```xml
<md:MarkdownScrollViewer>
# Heading1
Hello Markdown.Avalonia!
</md:MarkdownScrollViewer>
```
3. [With binding](https://github.com/whistyun/Markdown.Avalonia/wiki/How-to-use#With-binding)
```xml
<md:MarkdownScrollViewer
Markdown="{Binding MdText}"/>
```

**Preview**
![sc1](https://raw.githubusercontent.com/whistyun/Markdown.Avalonia/master/docs/img.demo/scrn1.png)
![sc2](https://raw.githubusercontent.com/whistyun/Markdown.Avalonia/master/docs/img.demo/scrn2.png)
30 changes: 30 additions & 0 deletions pack_readme/Markdown.Avalonia.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Markdown.Avalonia render Markdown with avalonia ui. It transform markdown to controls (ex: Border, Grid, TextBlock).

This package depends on AvaloniaEdit for syntax highlighting.
If you don't want it, use [Markdown.Avalonia.Tight](https://www.nuget.org/packages/Markdown.Avalonia.Tight) instead.

**How to use**

Markdown.Avalonia supports three methods to render markdown.

1. [Load .md from AvaloniaResource](https://github.com/whistyun/Markdown.Avalonia/wiki/How-to-use#Load-.md-from-AvaloniaResource)
```xml
<md:MarkdownScrollViewer
Source="avares://YourAssemblyName/Assets/Test.md"/>
```
2. [Write markdown in xaml](https://github.com/whistyun/Markdown.Avalonia/wiki/How-to-use#Write-markdown-in-xaml)
```xml
<md:MarkdownScrollViewer>
# Heading1
Hello Markdown.Avalonia!
</md:MarkdownScrollViewer>
```
3. [With binding](https://github.com/whistyun/Markdown.Avalonia/wiki/How-to-use#With-binding)
```xml
<md:MarkdownScrollViewer
Markdown="{Binding MdText}"/>
```

**Preview**
![sc1](https://raw.githubusercontent.com/whistyun/Markdown.Avalonia/master/docs/img.demo/scrn1.png)
![sc2](https://raw.githubusercontent.com/whistyun/Markdown.Avalonia/master/docs/img.demo/scrn2.png)
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
</ScrollViewer>
</Border.Child>
</Border>
<m:Rule BoldLineWidth="2" Classes="Bold" />
<m:Rule BoldLineWidth="2" Classes="Bold" />
<m:Rule BoldLineWidth="2" Classes="Bold" />
<m:Rule BoldLineWidth="2" Classes="Bold" />
<m:Rule BoldLineWidth="2" Classes="Bold" />
<m:Rule BoldLineWidth="2" Classes="Bold" />
<c:CTextBlock Classes="Paragraph">
<c:CRun Text="Underscores:" />
</c:CTextBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,38 @@
<c:CRun Text="asterisk 3" />
</c:CTextBlock>
</StackPanel>
<c:CTextBlock Classes="ListMarker" Grid.Column="0" Grid.Row="3">
<c:CRun Text="•" />
</c:CTextBlock>
<StackPanel Grid.Column="1" Grid.Row="3">
<c:CTextBlock Classes="Paragraph">
<c:CBold>
<c:CRun Text="bold" />
</c:CBold>
</c:CTextBlock>
</StackPanel>
<c:CTextBlock Classes="ListMarker" Grid.Column="0" Grid.Row="4">
<c:CRun Text="•" />
</c:CTextBlock>
<StackPanel Grid.Column="1" Grid.Row="4">
<c:CTextBlock Classes="Paragraph">
<c:CItalic>
<c:CRun Text="italic" />
</c:CItalic>
</c:CTextBlock>
</StackPanel>
<c:CTextBlock Classes="ListMarker" Grid.Column="0" Grid.Row="5">
<c:CRun Text="•" />
</c:CTextBlock>
<StackPanel Grid.Column="1" Grid.Row="5">
<c:CTextBlock Classes="Paragraph">
<c:CBold>
<c:CItalic>
<c:CRun Text="bold italic" />
</c:CItalic>
</c:CBold>
</c:CTextBlock>
</StackPanel>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
Expand All @@ -171,6 +203,9 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
<m:Rule BoldLineWidth="2" Classes="Bold" />
Expand Down
12 changes: 12 additions & 0 deletions tests/UnitTest.Md/Texts/HorizontalRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ Asterisks:

* * *

***

***

***

* * *

* * *

* * *


Underscores:

Expand Down
6 changes: 6 additions & 0 deletions tests/UnitTest.Md/Texts/Lists1.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Asterisks loose:

* asterisk 3

* **bold**

* *italic*

* ***bold italic***

* * *

Pluses tight:
Expand Down

0 comments on commit 9620488

Please sign in to comment.