-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
255 lines (200 loc) · 7.79 KB
/
index.html
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>micro-down</title>
<link href="https://fonts.googleapis.com/css?family=Ubuntu:400,400i,700" rel="stylesheet">
<style>
html {
font-family: "Ubuntu", sans-serif;
}
body {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
flex-direction: row;
margin: 0;
max-height: 100vh;
}
h1, h2, h3, h4, h5, h6 {
line-height: 1;
}
h2, h3, h4, h5, h6 {
margin-top: 50px;
}
img {
max-width: 75%;
display: block;
margin: auto;
}
#input {
height: 100vh;
width: 50%;
resize: none;
padding: 0;
margin: 0;
border: none;
}
#result {
float: left;
display: inline-block;
box-sizing: border-box;
width: 50%;
height: 100vh;
padding: 1rem;
margin: 0;
overflow: auto;
scroll-behavior: smooth;
}
.red {
color: red;
}
.gray {
background: #cccccc;
}
.logo {
max-width: 200px;
height: auto;
}
th, td {
padding: 2px 15px 2px 2px;
border-bottom: 1px solid #666;
background: #ffffff;
}
th:nth-child(odd) {
background: #ffF9ee;
}
td:nth-child(odd) {
background: #ffF9ee;
}
blockquote {
padding: 4px;
background: #ffffdd;
box-shadow: 2px 2px 4px #999999;
border: 1px solid #cccccc;
}
.center {
text-align: center;
}
.navigation {
background-color: #D6EDFF;
padding: .1rem 1rem;
}
.navigation a:hover {
background-color: #006FED;
}
.navigation a {
display: inline-block;
padding: .5rem 1rem;
background-color: #008DFE;
color: #FFFFFF;
text-decoration: none;
}
</style>
<script>
"use strict";var microdown=function(){function l(n,e,r){return"<"+n+(r?" "+Object.keys(r).map(function(n){return r[n]?n+'="'+(a(r[n])||"")+'"':""}).join(" "):"")+">"+e+"</"+n+">"}function c(n,e){return e=n.match(/^[+-]/m)?"ul":"ol",n?"<"+e+">"+n.replace(/(?:[+-]|\d+\.) +(.*)\n?(([ \t].*\n?)*)/g,function(n,e,r){return"<li>"+g(e+"\n"+(t=r||"").replace(new RegExp("^"+(t.match(/^\s+/)||"")[0],"gm"),"").replace(o,c))+"</li>";var t})+"</"+e+">":""}function e(r,t,u,c){return function(n,e){return n=n.replace(t,u),l(r,c?c(n):n)}}function t(n,u){return f(n,[/<!--((.|\n)*?)-->/g,"\x3c!--$1--\x3e",/^("""|```)(.*)\n((.*\n)*?)\1/gm,function(n,e,r,t){return'"""'===e?l("div",p(t,u),{class:r}):u&&u.preCode?l("pre",l("code",a(t),{class:r})):l("pre",a(t),{class:r})},/(^>.*\n?)+/gm,e("blockquote",/^> ?(.*)$/gm,"$1",r),/((^|\n)\|.+)+/g,e("table",/^.*(\n\|---.*?)?$/gm,function(n,t){return e("tr",/\|(-?)([^|]*)\1(\|$)?/gm,function(n,e,r){return l(e||t?"th":"td",g(r))})(n.slice(0,n.length-(t||"").length))}),o,c,/#\[([^\]]+?)]/g,'<a name="$1"></a>',/^(#+) +(.*)(?:$)/gm,function(n,e,r){return l("h"+e.length,g(r))},/^(===+|---+)(?=\s*$)/gm,"<hr>"],p,u)}var i=this,a=function(n){return n?n.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"):""},o=/(?:(^|\n)([+-]|\d+\.) +(.*(\n[ \t]+.*)*))+/g,g=function c(n,i){var o=[];return n=(n||"").trim().replace(/`([^`]*)`/g,function(n,e){return"\\"+o.push(l("code",a(e)))}).replace(/[!&]?\[([!&]?\[.*?\)|[^\]]*?)]\((.*?)( .*?)?\)|(\w+:\/\/[$\-.+!*'()/,\w]+)/g,function(n,e,r,t,u){return u?i?n:"\\"+o.push(l("a",u,{href:u})):"&"==n[0]?(e=e.match(/^(.+),(.+),([^ \]]+)( ?.+?)?$/),"\\"+o.push(l("iframe","",{width:e[1],height:e[2],frameborder:e[3],class:e[4],src:r,title:t}))):"\\"+o.push("!"==n[0]?l("img","",{src:r,alt:e,title:t}):l("a",c(e,1),{href:r,title:t}))}),n=function r(n){return n.replace(/\\(\d+)/g,function(n,e){return r(o[Number.parseInt(e)-1])})}(i?n:r(n))},r=function t(n){return f(n,[/([*_]{1,3})((.|\n)+?)\1/g,function(n,e,r){return e=e.length,r=t(r),1<e&&(r=l("strong",r)),e%2&&(r=l("em",r)),r},/(~{1,3})((.|\n)+?)\1/g,function(n,e,r){return l([,"u","s","del"][e.length],t(r))},/ \n|\n /g,"<br>"],t)},f=function(n,e,r,t){for(var u,c=0;c<e.length;){if(u=e[c++].exec(n))return r(n.slice(0,u.index),t)+("string"==typeof e[c]?e[c].replace(/\$(\d)/g,function(n,e){return u[e]}):e[c].apply(i,u))+r(n.slice(u.index+u[0].length),t);c++}return n},p=function(n,e){n=n.replace(/[\r\v\b\f]/g,"").replace(/\\./g,function(n){return"&#"+n.charCodeAt(1)+";"});var r=t(n,e);return r!==n||r.match(/^[\s\n]*$/i)||(r=g(r).replace(/((.|\n)+?)(\n\n+|$)/g,function(n,e){return l("p",e)})),r.replace(/&#(\d+);/g,function(n,e){return String.fromCharCode(parseInt(e))})};return{parse:p,block:t,inline:r,inlineBlock:g}}();"undefined"!=typeof module&&(module.exports=microdown);
</script>
</head>
<body>
<script>
const updateResult = function () {
document.getElementById('result').innerHTML = microdown.parse(document.getElementById('input').value, {preCode: true});
};
</script>
<div id="result"></div>
<textarea id="input" onkeyup="updateResult()">
""" center
![micro-down logo](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg)
-------------------------
# micro-down
=========================
"""
**1.3kB** JavaScript markdown parser
[view on GitHub](https://github.com/shynrou/micro-down)
""" navigation
[Inline Markup](#inline)
[Blocks](#blocks)
[Media](#media)
[Lists](#lists)
[Table](#table)
"""
#[inline]
## Inline Markup
_italic:_ \*italic\* \_italic\_
__bold:__ `**bold** __bold__`
___bold italic:___ `***bold italic*** ___bold italic___`
```
code: `code`
```
~underline:~ `~underline~`
~~strike through:~~ `~~strike through~~`
~~~deleted:~~~ `~~~deleted~~~`
#[blocks]
## Blocks
""" center gray
Div Blocks are surrounded by """ and can receive a classes.
"""
``` not_javascript
Pre
formatted
blocks
can
be defined
with ``` surrounding them,
they can also receive classes.
Tabs work here too!
```
> Block quotes can also be handy.
> They are very nice to get some interresting content
>
> "Blocks in general support _~inline~_ __styles__"
#[media]
## Media
### Links
``` markdown
[github](http://github.com Just a hover text!)
or simply as URL via auto linking https://github.com/commit-intl/micro-down
```
[github](http://github.com Just a hover text!)
or simply as URL via auto linking https://github.com/commit-intl/micro-down
### Images
``` markdown
![github](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg micro-down logo)
```
![github](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg micro-down logo)
combined:
``` markdown
[![github](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg micro-down logo)](http://github.com Just a hover text!)
```
[![github](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg micro-down logo)](http://github.com Just a hover text!)
### IFrames
``` markdown
&[340,170,0 project-card](https://github.com/commit-intl/micro-down)
```
&[340,170,0 project-card](https://github.com/commit-intl/micro-down)
#[lists]
## lists
1. Lists can be structured and layered
1. like this
2. for example
2. __and can also be mixed__
- like
+ this
3. _~inline works here to~_
and can be quite handy
#[table]
## Table
|-this -|-is -|-a -
| really | useless | table
| even more | useless | row
| this | is also | quite useless
|---
| but images, links and code works here too | ![micro-down logo](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg) | [micro-down logo](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg)
| fancy you know | `![micro-down logo](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg)` | `[micro-down logo](https://raw.githubusercontent.com/commit-intl/micro-down/master/microdown.svg)`
</textarea>
<script>updateResult();</script>
</body>
</html>