-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
index.html
174 lines (145 loc) · 6.35 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>micromarkdown.js</title>
<link href="./style.css" rel="stylesheet" type="text/css">
<link href="./mmd.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./micromarkdown.js"></script>
<!--<script type="text/javascript" src="./dist/micromarkdown.min.js"></script>-->
<script>
function parseMD() {
if (document.getElementById('htmlcb').checked !== false) {
document.getElementById('htmlexport').className = 'source';
document.getElementById('htmlexport').innerHTML = micromarkdown.htmlEncode(micromarkdown.parse(document.getElementById('md').value));
} else {
document.getElementById('htmlexport').className = 'preview';
document.getElementById('htmlexport').innerHTML = micromarkdown.parse(document.getElementById('md').value);
}
}
function resizeTA() {
var parent, child, width, height;
parent = document.getElementById('markdown');
child = document.getElementById('md');
height = parent.clientHeight-50;
width = parent.clientWidth-50;
child.style.height = height+'px';
child.style.width = width+'px';
}
window.onload = function() {
input = document.getElementById('defaultmd').innerHTML.split('<!--')[1].split('-->')[0];
document.getElementById('md').value = input;
micromarkdown.useajax = function() {
parseMD();
};
if(window.attachEvent) {
window.attachEvent('onresize', function() {
resizeTA();
});
}
else if(window.addEventListener) {
window.addEventListener('resize', function() {
resizeTA();
}, true);
}
parseMD();
resizeTA();
}
</script>
</head>
<body>
<a class="ribbon" href="https://github.com/SimonWaldherr/micromarkdown.js" target="_blank">
<img alt="Fork micromarkdown.js on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png">
</a>
<div id="html">
<input name="htmlcb" id="htmlcb" type="checkbox" onchange="javascript:parseMD();"><label for="htmlcb">‹/›</label>
</div>
<table id="table">
<tr>
<th>markdown</th><th>preview</th>
</tr>
<tr>
<td id="markdown"><textarea id="md" onkeyup="javascript:parseMD();"></textarea></td>
<td id="htmlexport"></td>
</tr>
</table>
<code id="defaultmd">
<!--
#![µmd.js](http://simonwaldherr.de/umd.png)
a tiny script to convert [markdown](http://en.wikipedia.org/wiki/Markdown) to [HTML](http://en.wikipedia.org/wiki/HTML) in under 5kb and under [MIT License](http://opensource.org/licenses/MIT).
```
[howto make a link in markdown](http://example.tld/)
```
[Lorem ipsum](http://en.wikipedia.org/wiki/Lorem_ipsum) **dolor** sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea **commodo** consequat. Duis *aute **irure dolor** in* reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint **occaecat cupidatat** non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo ~~inventore~~ inventari veritatis et quasi ***architecto beatae vitae dicta*** sunt, explicabo.
1. At vero eos et accusamus et iusto odio dignissimos ducimus
1. Qui blanditiis praesentium voluptatum deleniti atque corrupti
* Quos dolores et quas molestias excepturi sint
* Obcaecati *cupiditate **non** provident*
* Et harum quidem rerum facilis est et expedita distinctio
1. Neque porro quisquam
2. est qui dolorem ipsum
3. quia dolor sit amet
4. consectetur adipisci velit
1. Quis autem vel eum iure reprehenderit
1. qui in ea voluptate velit esse
Quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?
The previous text is only a lorem ipsum **placeholder text** to demonstrate **µmarkdown.js**. You can take a look at the code at <https://github.com/SimonWaldherr/micromarkdown.js> or view some of my other projects on [my GitHub page](https://github.com/SimonWaldherr/).
---
as an example of what you can do with markdown, here is a nice table:
this | *left* | center | right
-----|:-------|:--------:|------:
with | sample | content | for
lorem| ipsum | dolor | sit
sit | amet | sed | do
do | eiusom | tempor | with
you can also write down code-examples in markdown:
```
var md = document.getElementById("md").value,
html = micromarkdown.parse(md);
```
or include content from [other sources][source] *(this is only possible with micromarkdown)*:
[source]: http://cdn.simon.waldherr.eu/projects/majaX/content/data.csv
<include csv from http://cdn.simon.waldherr.eu/projects/majaX/content/data.csv>
to include µmarkdown on your page add
```
<script type="text/javascript"
src="http://simonwaldherr.github.io/micromarkdown.js/micromarkdown.js">
</script>
```
to your HTML Head and than use
```
var input = document.getElementById('input').value,
outputEle = document.getElementById('outEle');
outputEle.innerHTML = micromarkdown.parse(input);
```
to convert markdown to html.
please take a look at some of my other projects:
* [selfCSS](http://selfcss.org/)
* [PodloveWebPlayer](http://podlove.org/podlove-web-player/)
* [Shownot.es](http://shownot.es/)
* [FAMOUS](http://famous-project.org/)
* and many more on [github.com](https://github.com/SimonWaldherr?tab=repositories)
you can find me on:
* App.net @SimonWaldherr@adn
* Twitter @SimonWaldherr@t
* GitHub @SimonWaldherr@gh
* Facebook @SimonWaldherr@fb
* Google+ @SimonWaldherr@gp
most markdown scripts also allow to include HTML:
---
<span style="position:absolute;right:25px;">micromarkdown.js</span>
-->
</code>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33526676-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>