|
| 1 | +<!-- Copyright 2014 Google Inc. All rights reserved. |
| 2 | +
|
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | +
|
| 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +
|
| 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +See the License for the specific language governing permissions and |
| 13 | +limitations under the License. |
| 14 | +--> |
| 15 | + |
| 16 | +<!-- Code Block |
| 17 | + Code block elements are used to wrap program fragments in C++. |
| 18 | +
|
| 19 | + For improved source clarity, this element removes leading and trailing |
| 20 | + whitespace from its contents. |
| 21 | +
|
| 22 | + This element also prevents the HTML parser from ending a surrounding <p> tag |
| 23 | + when it sees the opening <pre>. |
| 24 | +
|
| 25 | + TODO: This could call into a syntax highlighter that styles |
| 26 | + comments correctly. |
| 27 | +--> |
| 28 | +<polymer-elementname="cxx-codeblock"> |
| 29 | +<template> |
| 30 | +<style> |
| 31 | +:host { display: block; } |
| 32 | +</style> |
| 33 | +<pre><code><content></content></code></pre> |
| 34 | +</template> |
| 35 | +<script> |
| 36 | +Polymer('cxx-codeblock',{ |
| 37 | +attached:function(){ |
| 38 | +if(this.firstChild.nodeType==Node.TEXT_NODE) |
| 39 | +this.firstChild.nodeValue=this.firstChild.nodeValue.replace(/^\s+/,''); |
| 40 | +if(this.lastChild.nodeType==Node.TEXT_NODE) |
| 41 | +this.lastChild.nodeValue=this.lastChild.nodeValue.replace(/\s+$/,''); |
| 42 | +} |
| 43 | +}); |
| 44 | +</script> |
| 45 | +</polymer-element> |
| 46 | + |