forked from ppy/osu-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCaseMarkdown.cs
More file actions
163 lines (142 loc) · 4.96 KB
/
Copy pathTestCaseMarkdown.cs
File metadata and controls
163 lines (142 loc) · 4.96 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.ComponentModel;
using System.Threading.Tasks;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Framework.IO.Network;
using osu.Framework.Testing;
namespace osu.Framework.Tests.Visual.TestCaseUserInterface
{
[Description("markdown reader")]
public class TestCaseMarkdown : TestCase
{
public TestCaseMarkdown()
{
MarkdownContainer markdownContainer;
Add(markdownContainer = new MarkdownContainer
{
RelativeSizeAxes = Axes.Both,
});
AddStep("Markdown Heading", () =>
{
markdownContainer.Text = @"# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5";
});
AddStep("Markdown Seperator", () =>
{
markdownContainer.Text = @"Line above
---
Line below";
});
AddStep("Markdown Heading", () =>
{
markdownContainer.Text = @"- [1. Blocks](#1-blocks)
- [1.1 Code block](#11-code-block)
- [1.2 Text block](#12-text-block)
- [1.3 Escape block](#13-escape-block)
- [1.4 Whitespace control](#14-whitespace-control)
- [2 Comments](#2-comments)
- [3 Literals](#3-literals)
- [3.1 Strings](#31-strings)
- [3.2 Numbers](#32-numbers)
- [3.3 Boolean](#33-boolean)
- [3.4 null](#34-null)";
});
AddStep("Markdown Quote", () =>
{
markdownContainer.Text = @"> **input**";
});
AddStep("Markdown Fenced Code", () =>
{
markdownContainer.Text = @"```scriban-html
{{
x = ""5"" # This assignment will not output anything
x # This expression will print 5
x + 1 # This expression will print 6
}}
```";
});
AddStep("Markdown Fenced Code (CSharp)", () =>
{
markdownContainer.Text = @"```csharp
// A Hello World! program in C#.
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine(""Hello World!"");
// Keep the console window open in debug mode.
Console.WriteLine(""Press any key to exit."");
Console.ReadKey();
}
}
}
```";
});
AddStep("Markdown Table", () =>
{
markdownContainer.Text =
@"|Operator | Description
|--------------------|------------
| `'left' + <right>` | concatenates left to right string: `""ab"" + ""c"" -> ""abc""`
| `'left' * <right>` | concatenates the left string `right` times: `'a' * 5 -> aaaaa`. left and right and be swapped as long as there is one string and one number.";
});
AddStep("Markdown Table (Aligned)", () =>
{
markdownContainer.Text =
@"| Left-Aligned | Center Aligned | Right Aligned |
| :------------ |:---------------:| -----:|
| col 3 is | some wordy text | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |";
});
AddStep("Markdown Paragraph 1", () =>
{
markdownContainer.Text = @"A text enclosed by `{{` and `}}` is a scriban **code block** that will be evaluated by the scriban templating engine.";
});
AddStep("Markdown Paragraph 2", () =>
{
markdownContainer.Text =
@"The greedy mode using the character - (e.g {{- or -}}), removes any whitespace, including newlines Examples with the variable name = ""foo"":";
});
AddStep("MarkdownLink", () =>
{
markdownContainer.Text = @"[click the circles to the beat](https://osu.ppy.sh)";
});
AddStep("MarkdownImage", () =>
{
markdownContainer.Text = @"";
});
AddStep("MarkdownFromInternet", () =>
{
const string url = "https://raw.githubusercontent.com/ppy/osu-wiki/master/wiki/Skinning/skin.ini/en.md";
markdownContainer.RootUrl = url;
var req = new WebRequest(url);
req.Finished += () => markdownContainer.Text = req.ResponseString;
Task.Run(() => req.PerformAsync());
});
AddStep("Emphases", () =>
{
markdownContainer.Text = @"_italic with underscore_
*italic with asterisk*
__bold with underscore__
**bold with asterisk**
*__italic with asterisk, bold with underscore__*
_**italic with underscore, bold with asterisk**_";
});
AddStep("new lines", () =>
{
markdownContainer.Text = @"line 1
soft break\
soft break with '\'";
});
}
}
}