forked from xen/markdown-tg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
44 lines (41 loc) · 1.19 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
<html>
<head>
<meta charset="utf-8">
<title>Markdown-tg.js</title>
<script src="markdown-tg.min.js"></script>
</head>
<body>
<textarea id="input" rows="10" cols="100">
*bold text*
_italic text_
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
`inline fixed-width code`
```block_language
pre-formatted fixed-width code block
```
</textarea>
<br />
<button onclick="javascrpt:render()">Render</button>
<br />
<div id="output"></div>
<script>
// full render constructor
function render() {
var input = document.getElementById('input').value;
var rules = markdownTg.defaultRules;
var parse = markdownTg.defaultInlineParse;
var htmlOutput = markdownTg.htmlFor(markdownTg.ruleOutput(rules, 'html'));
var output = document.getElementById("output");
var syntaxTree = parse(input);
output.innerHTML = htmlOutput(syntaxTree).replace(/(?:\r\n|\r|\n)/g, '<br />');
return htmlOutput(syntaxTree);
};
render();
// simpliest render with all defaults
function simpleRender(text){
return markdownTg.defaultHtmlOutput(markdownTg.defaultParse(text));
}
</script>
</body>
</html>