-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathMarkdownParserPage.xaml.cs
42 lines (36 loc) · 1.29 KB
/
MarkdownParserPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.Toolkit.Parsers.Markdown;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MarkdownParserPage : Page
{
public MarkdownParserPage()
{
this.InitializeComponent();
this.Loaded += MarkdownParserPage_Loaded;
}
private void MarkdownParserPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
UpdateMDResult();
}
private void RawMarkdown_TextChanged(object sender, TextChangedEventArgs e)
{
UpdateMDResult();
}
private void UpdateMDResult()
{
var document = new MarkdownDocument();
document.Parse(RawMarkdown.Text);
var json = JsonConvert.SerializeObject(document, Formatting.Indented, new StringEnumConverter());
MarkdownResult.Text = json;
}
}
}