Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
remove white-space stripping that was confusing the doc viewer (does …
Browse files Browse the repository at this point in the history
…it regress something else?)
  • Loading branch information
Scott J. Miles committed Mar 5, 2014
1 parent 14b6f6a commit 3e133fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
17 changes: 15 additions & 2 deletions demo.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
Expand All @@ -11,14 +11,27 @@
<script src="../platform/platform.js"></script>
<link rel="import" href="marked-js.html">
</head>
<body>
<body unresolved>
<marked-js>
## Markdown Renderer

* implemented in `JavaScript`
* realtime formatting

Example:

<div>
<polymer-overlay></polymer-overlay>
<h2>Dialog</h2>
<input placeholder="say something..." autofocus>
<div>I agree with this wholeheartedly.</div>
<button overlay-toggle>OK</button>
</div>

_Nifty_ features.
</marked-js>

<marked-js text=" <div>div</div>"></marked-js>

</body>
</html>
14 changes: 10 additions & 4 deletions marked-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@
<script src="marked/marked.js"></script>

<polymer-element name="marked-js" attributes="text">

<script>
Polymer('marked-js', {

text: '',
allowAuthorStyles: true,
enteredView: function() {

enteredView: function() {
marked.setOptions({
highlight: this.highlight.bind(this)
});
if (!this.text) {
this.text = this.innerHTML;
}
},

textChanged: function () {
this.innerHTML = marked(this.text.replace(/^[^\S\n]+/gm,''));
this.innerHTML = marked(this.text);
},

highlight: function(code, lang) {
return this.fire('marked-js-highlight', {code: code, lang: lang}).code || code;
var event = this.fire('marked-js-highlight', {code: code, lang: lang});
return event.detail.code || code;
}

});
</script>

</polymer-element>

0 comments on commit 3e133fb

Please sign in to comment.