Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit 50f6d69

Browse files
committed
Merge pull request evilstreak#62 from Sentido-Labs/master
Update the README: markdown-js works fine in browsers
2 parents f32b7be + e5495f4 commit 50f6d69

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.markdown

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,29 @@ If you want more control check out the documentation in
4646
available (including examples!). One day we'll get the docs generated
4747
and hosted somewhere for nicer browsing.
4848

49-
We're yet to try it out in a browser, though it's high up on our list of
50-
things to sort out for this project.
49+
It also works in a browser; here is a complete example:
50+
51+
<!DOCTYPE html>
52+
<html>
53+
<body>
54+
<textarea id="text-input" oninput="this.editor.update()"
55+
rows="6" cols="60">Type **Markdown** here.</textarea>
56+
<div id="preview"> </div>
57+
<script src="lib/markdown.js"></script>
58+
<script>
59+
function Editor(input, preview)
60+
{
61+
this.update = function () {
62+
preview.innerHTML = markdown.toHTML(input.value);
63+
}
64+
input.editor = this;
65+
this.update();
66+
}
67+
var $ = function (id) { return document.getElementById(id); };
68+
new Editor($("text-input"), $("preview"));
69+
</script>
70+
</body>
71+
</html>
5172

5273
### md2html
5374

0 commit comments

Comments
 (0)