OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
6 Code distributed by Google as part of the polymer project is also | |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
8 --> | |
9 | |
10 <link rel="import" href="../polymer/polymer.html"> | |
11 <link rel="import" href="marked-import.html"> | |
12 | |
13 <!-- | |
14 Element wrapper for the `marked` (http://marked.org/) library. | |
15 | |
16 @class marked-element | |
17 @blurb Element wrapper for the marked library. | |
18 @status alpha | |
19 @snap snap.png | |
20 --> | |
21 <polymer-element name="marked-element" attributes="text"> | |
22 <script> | |
23 | |
24 Polymer('marked-element', { | |
25 | |
26 text: '', | |
27 | |
28 attached: function() { | |
29 marked.setOptions({ | |
30 highlight: this.highlight.bind(this) | |
31 }); | |
32 if (!this.text) { | |
33 this.text = this.innerHTML; | |
34 } | |
35 }, | |
36 | |
37 textChanged: function () { | |
38 this.innerHTML = marked(this.text); | |
39 }, | |
40 | |
41 highlight: function(code, lang) { | |
42 var event = this.fire('marked-js-highlight', {code: code, lang: lang}); | |
43 return event.detail.code || code; | |
44 } | |
45 | |
46 }); | |
47 | |
48 </script> | |
49 </polymer-element> | |
50 | |
OLD | NEW |