Skip to content

Commit 56db06c

Browse files
UpdatedTests
1 parent 49f18ff commit 56db06c

File tree

3 files changed

+251
-11
lines changed

3 files changed

+251
-11
lines changed

DotNetElements.Wpf.Markdown.Example/MainWindow.xaml.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.IO;
2-
using System.Windows;
1+
using System.Windows;
32
using CommunityToolkit.Mvvm.ComponentModel;
43
using CommunityToolkit.Mvvm.Input;
54
using DotNetElements.Wpf.Markdown.Core;
@@ -19,7 +18,6 @@ public MainWindow()
1918
MarkdownTextBlock.MarkdownParsedCommand = new RelayCommand<MarkdownDocument>(MarkdownTextBlock_OnMarkdownParsedCommand);
2019

2120
MarkdownConfig config = MarkdownConfig.Default;
22-
config.FeaturePipeTablesSupported = false;
2321
MarkdownTextBlock.Config = config;
2422

2523
MarkdownInput.Text = ExampleMarkdown;

DotNetElements.Wpf.Markdown.Tests/DocumentMarkdownWriterSnapshotTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ public async Task RendersMarkdownCorrectly()
1717
MdFlowDocument document = new();
1818
document.Document.FontFamily = new FontFamily("Segoe UI"); // todo check if we want this in config
1919
document.Document.Background = new SolidColorBrush(Colors.White); // todo check if we want this in config
20-
DocumentMarkdownWriter renderer = new(document, (uri) => { }); // todo pass fixed test config
20+
DocumentMarkdownWriter renderer = new(document, (uri) => { }, MarkdownConfig.Default); // todo pass fixed test config
2121

2222
MarkdownPipeline pipeline = new MarkdownPipelineBuilder()
2323
.UseEmphasisExtras()
24-
//.UseAutoLinks()
25-
.UseTaskLists() // todo check if feature is enabled in config >>> need to reset the pipeline if the config changes
26-
.UsePipeTables() // todo check if feature is enabled in config >>> need to reset the pipeline if the config changes
27-
.UseAlertBlocks() // todo check if feature is enabled in config >>> need to reset the pipeline if the config changes
24+
.UseTaskLists()
25+
.UsePipeTables()
26+
.UseAlertBlocks()
27+
.UseAutoLinks()
2828
.Build();
2929

3030
pipeline.Setup(renderer);

DotNetElements.Wpf.Markdown.Tests/SnapshotResults/DocumentMarkdownWriterSnapshotTests.RendersMarkdownCorrectly.verified.txt

Lines changed: 245 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,64 @@
237237
FontWeight="Normal"
238238
FontSize="12"
239239
Foreground="#FF000000"
240-
Background="#FFD3D3D3"
241-
xml:space="preserve">public class Test<LineBreak />{}{<LineBreak /> public void TestMethod()<LineBreak /> {<LineBreak /> Console.WriteLine("Hello World");<LineBreak /> }<LineBreak />}</Paragraph>
240+
Background="#FFD3D3D3">
241+
<Span
242+
xml:space="preserve" />
243+
<Span>
244+
<Run
245+
Foreground="#FF0000FF">public</Run>
246+
</Span>
247+
<Span
248+
xml:space="preserve" />
249+
<Span
250+
xml:space="preserve"> </Span>
251+
<Span
252+
xml:space="preserve" />
253+
<Span>
254+
<Run
255+
Foreground="#FF0000FF">class</Run>
256+
</Span>
257+
<Span
258+
xml:space="preserve" />
259+
<Span
260+
xml:space="preserve"> Test
261+
{
262+
</Span>
263+
<Span
264+
xml:space="preserve" />
265+
<Span>
266+
<Run
267+
Foreground="#FF0000FF">public</Run>
268+
</Span>
269+
<Span
270+
xml:space="preserve" />
271+
<Span
272+
xml:space="preserve"> </Span>
273+
<Span
274+
xml:space="preserve" />
275+
<Span>
276+
<Run
277+
Foreground="#FF0000FF">void</Run>
278+
</Span>
279+
<Span
280+
xml:space="preserve" />
281+
<Span
282+
xml:space="preserve"> TestMethod()
283+
{
284+
Console.WriteLine(</Span>
285+
<Span
286+
xml:space="preserve" />
287+
<Span>
288+
<Run
289+
Foreground="#FFA31515">"Hello World"</Run>
290+
</Span>
291+
<Span
292+
xml:space="preserve" />
293+
<Span
294+
xml:space="preserve">);
295+
}
296+
}</Span>
297+
</Paragraph>
242298
<Paragraph>
243299
<Line
244300
X2="1"
@@ -416,4 +472,190 @@
416472
<Paragraph>Row 1</Paragraph>
417473
</TableCell>
418474
</TableRow>
419-
</TableRowGroup>
475+
</TableRowGroup>
476+
<TableRowGroup>
477+
<TableRow
478+
Background="#00FFFFFF">
479+
<TableCell
480+
Padding="5,3,5,3"
481+
BorderThickness="0,0,1,1"
482+
BorderBrush="#FF808080"
483+
TextAlignment="Left">
484+
<Paragraph>Row 2</Paragraph>
485+
</TableCell>
486+
<TableCell
487+
Padding="5,3,5,3"
488+
BorderThickness="0,0,1,1"
489+
BorderBrush="#FF808080"
490+
TextAlignment="Left">
491+
<Paragraph>Row 2</Paragraph>
492+
</TableCell>
493+
<TableCell
494+
Padding="5,3,5,3"
495+
BorderThickness="0,0,1,1"
496+
BorderBrush="#FF808080"
497+
TextAlignment="Left">
498+
<Paragraph>Row 2</Paragraph>
499+
</TableCell>
500+
</TableRow>
501+
</TableRowGroup>
502+
</Table>
503+
<Paragraph>This is a table with defined text alignment</Paragraph>
504+
<Table
505+
CellSpacing="0"
506+
BorderThickness="1,1,0,0"
507+
BorderBrush="#FF808080">
508+
<Table.Columns>
509+
<TableColumn />
510+
<TableColumn />
511+
<TableColumn />
512+
</Table.Columns>
513+
<TableRowGroup>
514+
<TableRow
515+
Background="#FFADD8E6">
516+
<TableCell
517+
Padding="5,3,5,3"
518+
BorderThickness="0,0,1,1"
519+
BorderBrush="#FF808080"
520+
TextAlignment="Left">
521+
<Paragraph>Header 1 (default)</Paragraph>
522+
</TableCell>
523+
<TableCell
524+
Padding="5,3,5,3"
525+
BorderThickness="0,0,1,1"
526+
BorderBrush="#FF808080"
527+
TextAlignment="Center">
528+
<Paragraph>Header 2 (center)</Paragraph>
529+
</TableCell>
530+
<TableCell
531+
Padding="5,3,5,3"
532+
BorderThickness="0,0,1,1"
533+
BorderBrush="#FF808080"
534+
TextAlignment="Right">
535+
<Paragraph>Header 3 (right)</Paragraph>
536+
</TableCell>
537+
</TableRow>
538+
</TableRowGroup>
539+
<TableRowGroup>
540+
<TableRow
541+
Background="#00FFFFFF">
542+
<TableCell
543+
Padding="5,3,5,3"
544+
BorderThickness="0,0,1,1"
545+
BorderBrush="#FF808080"
546+
TextAlignment="Left">
547+
<Paragraph>Row 1</Paragraph>
548+
</TableCell>
549+
<TableCell
550+
Padding="5,3,5,3"
551+
BorderThickness="0,0,1,1"
552+
BorderBrush="#FF808080"
553+
TextAlignment="Center">
554+
<Paragraph>Row 1</Paragraph>
555+
</TableCell>
556+
<TableCell
557+
Padding="5,3,5,3"
558+
BorderThickness="0,0,1,1"
559+
BorderBrush="#FF808080"
560+
TextAlignment="Right">
561+
<Paragraph>Row 1</Paragraph>
562+
</TableCell>
563+
</TableRow>
564+
</TableRowGroup>
565+
<TableRowGroup>
566+
<TableRow
567+
Background="#00FFFFFF">
568+
<TableCell
569+
Padding="5,3,5,3"
570+
BorderThickness="0,0,1,1"
571+
BorderBrush="#FF808080"
572+
TextAlignment="Left">
573+
<Paragraph>Row 2</Paragraph>
574+
</TableCell>
575+
<TableCell
576+
Padding="5,3,5,3"
577+
BorderThickness="0,0,1,1"
578+
BorderBrush="#FF808080"
579+
TextAlignment="Center">
580+
<Paragraph>Row 2</Paragraph>
581+
</TableCell>
582+
<TableCell
583+
Padding="5,3,5,3"
584+
BorderThickness="0,0,1,1"
585+
BorderBrush="#FF808080"
586+
TextAlignment="Right">
587+
<Paragraph>Row 2</Paragraph>
588+
</TableCell>
589+
</TableRow>
590+
</TableRowGroup>
591+
</Table>
592+
<Paragraph>
593+
<Line
594+
X2="1"
595+
Stretch="Fill"
596+
Stroke="#FF808080"
597+
StrokeThickness="2"
598+
Margin="0,12,0,12" />
599+
</Paragraph>
600+
<Section
601+
Margin="0,0,0,20"
602+
Padding="5,3,5,3"
603+
BorderThickness="5,0,0,0"
604+
BorderBrush="#FF6495ED"
605+
FontSize="14"
606+
Foreground="#FF000000"
607+
Background="#FFD3D3D3">
608+
<Paragraph
609+
Margin="0,0,0,10">
610+
<Run
611+
FontWeight="Bold"
612+
FontSize="14"
613+
Foreground="#FF6495ED">NOTE</Run>
614+
</Paragraph>
615+
<Paragraph
616+
Margin="Auto,0,Auto,0">Highlights information that users should take into account, even when skimming.</Paragraph>
617+
</Section>
618+
<Section
619+
Margin="0,0,0,20"
620+
Padding="5,3,5,3"
621+
BorderThickness="5,0,0,0"
622+
BorderBrush="#FF228B22"
623+
FontSize="14"
624+
Foreground="#FF000000"
625+
Background="#FFD3D3D3">
626+
<Paragraph
627+
Margin="0,0,0,10">
628+
<Run
629+
FontWeight="Bold"
630+
FontSize="14"
631+
Foreground="#FF228B22">TIP</Run>
632+
</Paragraph>
633+
<Paragraph
634+
Margin="Auto,0,Auto,0">Optional information to help a user be more successful.</Paragraph>
635+
</Section>
636+
<Section
637+
Margin="0,0,0,20"
638+
Padding="5,3,5,3"
639+
BorderThickness="5,0,0,0"
640+
BorderBrush="#FF800080"
641+
FontSize="14"
642+
Foreground="#FF000000"
643+
Background="#FFD3D3D3">
644+
<Paragraph
645+
Margin="0,0,0,10">
646+
<Run
647+
FontWeight="Bold"
648+
FontSize="14"
649+
Foreground="#FF800080">IMPORTANT</Run>
650+
</Paragraph>
651+
<Paragraph
652+
Margin="Auto,0,Auto,0">Crucial information necessary for users to succeed.</Paragraph>
653+
</Section>
654+
<Section
655+
Margin="0,0,0,20"
656+
Padding="5,3,5,3"
657+
BorderThickness="5,0,0,0"
658+
BorderBrush="#FFFCDB03"
659+
FontSize="14"
660+
Foreground="#FF000000"
661+

0 commit comments

Comments
 (0)