-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.ts
192 lines (126 loc) · 3.06 KB
/
example.ts
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import { renderMarkdown } from "./mod.ts";
export const demoText: string = `
# deno charmd
This is an example, to showcase https://github.com/littletof/charmd
If you want to test the module with your own markdown, provide its \`path\` as an argument and make sure \`--allow-read\` is also provided.
\`\`\`bash
deno run --allow-read https://raw.githubusercontent.com/littletof/charmd/master/mod.ts .\/README.md
\`\`\`
## Headers
# h1 Heading
h1 Heading with \`===\`
===
## h2 Heading
h2 Heading with \`---\`
---
### h3 Heading
#### h4 Heading
##### h5 Heading
###### h6 Heading
---
## Emphasis
**This is bold text \`\*\*\`**
__This is bold text \`\_\_\`__
*This is italic text \`\*\`*
_This is italic text \`\_\`_
~~This is strikethrough~~ \`\~\~\`
**an *italic* in bold**
~~**an *italic* in bold with \`striketrough\`**~~
## Blockquotes
> Blockquotes can also be nested...
>> ...by using additional greater-than signs right next to each other...
> > > ...or with spaces between arrows.
> Some quote
and more
>> Another quote
> Some quote
> with **bold** and \`block\`
> > and Another quote
>> >> #### and some more quote
## Lists
### Unordered
+ Create a list by starting a line with \`+\`, \`-\`, or \`*\`
- Indented list item:
* Subsublist item
+ Subsublist item
+ Main list item
### Ordered
1. Lorem ipsum dolor sit amet
2. Consectetur adipiscing elit
3. Integer molestie lorem at massa
### Task List
- [x] Some
- [ ] Other
## Code
Inline \`code\` *\`italics\`* **\`bold\`** ***\`both\`***
Indented code
// Some comments
line 1 of code
line 2 of code
line 3 of code
Block code "fences"
\`\`\`
Sample text here...
\`\`\`
Codeblock with lang
\`\`\`ts
function sum(...nums: number[]): number {
return nums.reduce((sum, num) => sum + num, 0);
}
\`\`\`
## Horizontal Rules
___
---
***
* * *
** ** ** ** **
--------------------
## Tables
| a | b | c |
| ----- | :---: | ----: |
| 123 | 456 | 789 |
| ABCDEF | DEFGHI | GHIJKL |
| left1 |left2| center | right |
|-------|:----|:-----:|----:|
| 123 | 456 | 789 | 101 |
| \`ABC\` | **DEF** | *GHI* | ![image](docs/showcase.png) |
> | a | b | c |
> | ----- | :---: | ----: |
> | 123 | 456 | 789 |
> | ABCDEF | DEFGHI | GHIJKL |
## Links
[Deno](https://deno.land)
[Bottom](#bottom)
[LinkReference]
[LinkReference]: https://deno.land/x
[link with title](https://deno.land "title text!")
Autoconverted link https://deno.land
## Images
![Deno](https://deno.land/logo.svg)
![Deno](https://deno.land/logo.svg "The Deno logo")
![Alt text][id]
[id]: https://deno.land/logo.svg "Deno logo"
## HTML
<h2>HTML</h2>
<hr />
<div>Some \`<div>\` tag</div>
<strong>and **\<strong>** tag</strong>
<br />
<footer align="center" id="bottom">
<a href="#headers-">
<strong>Top</strong>
<i class="fas fa-chevron-up"></i>
</a>
</footer>
---
`;
if (import.meta.main) {
let md;
if (Deno.args[0]) {
md = Deno.readTextFileSync(Deno.args[0]);
} else {
md = demoText;
}
// renderMarkdown(md)
console.log(renderMarkdown(md));
}