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.github.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/CONTRIBUTORS.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/PATENTS.txt
19 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
20 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
21 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
22 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
23 Code distributed by Google as part of the polymer project is also
24 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
28 The `core-layout` element is a helper for using
29 [CSS3 Flexible Boxes](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes).
30 A `core-layout` element enables a set of css selectors for easy flexbox styling.
36 <div core-flex>Main</div>
40 Renders something like this:
42 ---------------------------------
43 |-------------------------------|
45 |-------------------------------|
46 ---------------------------------
48 __Note__: the `core-layout` element applies layout to itself if it has children or to
49 its parent element, if it does not. This feature allows you to apply layout to an
52 Elements can layout horizontally, such that their items stack
53 left to right or vertically, such that their items stack top to bottom. The
54 default is horizontal. Set `vertical` to true to layout the elements vertically.
56 To make a particular child _flexible_, use the `core-flex` attribute.
57 You can control flexibility from 1 to 3 by giving the attribute a
58 corresponding value. For other values, apply the css manually.
60 It's common in flexbox parlance to hear the terms _main axis_ and _cross axis_.
61 For a horizontal layout the main axis is horizontal and the cross axis is vertical.
62 These are exchanged for a vertical layout.
64 To effect alignment in the main axis, use the `justify` attribute. The
65 supported values are `start`, `center`, `end`, and `between`.
67 To effect alignment in the cross axis, use the `align` attribute. The
68 supported values are `start`, `center`, and `end`.
70 Note, it's also possible to include the `core-layout.css` stylesheet separate
71 from the `core-layout` element. Including the element automatically includes
72 the stylesheet. To use the stylesheet independent of the element, css classes
73 should be used of the following form: `core-h`, `core-v`, `core-flex`,
74 `core-justify-start`, and `core-align-start`.
76 The `core-layout` and css file also provide a few commonly needed layout
77 behaviors. Apply the `core-fit` class to fit an element to its container. To
78 ensure a container will contain an element inside it with the `core-fit` class
79 give it the `core-relative` class.
83 <core-layout vertical>
86 <div core-flex>Body</div>
109 <core-layout justify="end">
110 <div core-flex>Left</div>
115 ---------------------------------
116 |-------------------------------|
118 |-------------------------------|
119 ---------------------------------
123 <core-layout align="center">
125 <div core-flex>Main</div>
129 ---------------------------------
130 |-------------------------------|
132 ||Left| Main |Right||
134 |-------------------------------|
135 ---------------------------------
138 To layout contents of a parent element, place a `core-layout` inside of it:
141 <core-layout></core-layout>
143 <div core-flex>Main</div>
147 ---------------------------------
148 |-------------------------------|
149 ||Left| Main |Right||
150 |-------------------------------|
151 ---------------------------------
153 You may also use the `core-layout` stylesheet directly:
155 <link rel="stylesheet" href="../core-layout/core-layout.css">
156 <div class="core-h core-justify-end">
157 <div core-flex>Left</div>
162 ---------------------------------
163 |-------------------------------|
165 |-------------------------------|
166 ---------------------------------
168 @group Polymer Core Elements
172 <link rel=
"import" href=
"../polymer/polymer.html">
174 <polymer-element name=
"core-layout" attributes=
"vertical justify align isContainer reverse" assetpath=
"../core-layout/">
179 Copyright
2013 The Polymer Authors. All rights reserved.
180 Use of this source code is governed by a BSD-style
181 license that can be found in the LICENSE file.
185 display: -webkit-box !important;
186 display: -ms-flexbox !important;
187 display: -moz-flex !important;
188 display: -webkit-flex !important;
189 display: flex !important;
193 -webkit-box-orient: horizontal;
194 -ms-flex-direction: row;
195 -moz-flex-direction: row;
196 -webkit-flex-direction: row;
200 .core-h.core-reverse {
201 -webkit-box-direction: reverse;
202 -ms-flex-direction: row-reverse;
203 -moz-flex-direction: row-reverse;
204 -webkit-flex-direction: row-reverse;
205 flex-direction: row-reverse;
209 -webkit-box-orient: vertical;
210 -ms-flex-direction: column;
211 -moz-flex-direction: column;
212 -webkit-flex-direction: column;
213 flex-direction: column;
216 .core-v.core-reverse {
217 -webkit-box-direction: reverse;
218 -ms-flex-direction: column-reverse;
219 -moz-flex-direction: column-reverse;
220 -webkit-flex-direction: column-reverse;
221 flex-direction: column-reverse;
240 .core-flex, [core-flex] {
248 .core-flex-auto, [core-flex-auto] {
252 -webkit-flex:
1 1 auto;
256 .core-flex-none, [core-flex-none] {
257 -webkit-box-flex: none;
264 .core-flex1, [core-flex=
1] {
272 .core-flex2, [core-flex=
2] {
280 .core-flex3, [core-flex=
3] {
288 /* distributed elements */
289 ::content
> .core-flex, ::content
> [core-flex] {
297 ::content
> .core-flex-auto, ::content
> [core-flex-auto] {
301 -webkit-flex:
1 1 auto;
305 ::content
> .core-flex-none, ::content
> [core-flex-none] {
306 -webkit-box-flex: none;
313 ::content
> .core-flex1, ::content
> [core-flex=
1] {
321 ::content
> .core-flex2, ::content
> [core-flex=
2] {
329 ::content
> .core-flex3, ::content
> [core-flex=
3] {
337 /* alignment in main axis */
338 .core-justify-start {
339 -webkit-box-pack: start;
340 -ms-flex-pack: start;
341 -moz-justify-content: flex-start;
342 -webkit-justify-content: flex-start;
343 justify-content: flex-start;
346 .core-justify-center {
347 -webkit-box-pack: center;
348 -ms-flex-pack: center;
349 -moz-justify-content: center;
350 -webkit-justify-content: center;
351 justify-content: center;
355 -webkit-box-pack: end;
357 -moz-justify-content: flex-end;
358 -webkit-justify-content: flex-end;
359 justify-content: flex-end;
362 .core-justify-between {
363 -webkit-box-pack: justify;
364 -ms-flex-pack: justify;
365 -moz-justify-content: space-between;
366 -webkit-justify-content: space-between;
367 justify-content: space-between;
370 /* alignment in cross axis */
372 -webkit-box-align: start;
373 -ms-flex-align: start;
374 -moz-align-items: flex-start;
375 -webkit-align-items: flex-start;
376 align-items: flex-start;
380 -webkit-box-align: center;
381 -ms-flex-align: center;
382 -moz-align-items: center;
383 -webkit-align-items: center;
388 -webkit-box-align: end;
390 -moz-align-items: flex-end;
391 -webkit-align-items: flex-end;
392 align-items: flex-end;
396 Copyright (c)
2014 The Polymer Project Authors. All rights reserved.
397 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
398 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
399 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
400 Code distributed by Google as part of the polymer project is also
401 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
405 display: -webkit-box !important;
406 display: -ms-flexbox !important;
407 display: -moz-flex !important;
408 display: -webkit-flex !important;
409 display: flex !important;
413 -webkit-box-orient: horizontal;
414 -ms-flex-direction: row;
415 -moz-flex-direction: row;
416 -webkit-flex-direction: row;
421 -webkit-box-orient: vertical;
422 -ms-flex-direction: column;
423 -moz-flex-direction: column;
424 -webkit-flex-direction: column;
425 flex-direction: column;
428 :host(.core-h.core-reverse) {
429 -webkit-box-direction: reverse;
430 -ms-flex-direction: row-reverse;
431 -moz-flex-direction: row-reverse;
432 -webkit-flex-direction: row-reverse;
433 flex-direction: row-reverse;
436 :host(.core-v.core-reverse) {
437 -webkit-box-direction: reverse;
438 -ms-flex-direction: column-reverse;
439 -moz-flex-direction: column-reverse;
440 -webkit-flex-direction: column-reverse;
441 flex-direction: column-reverse;
444 /* alignment in main axis */
445 :host(.core-justify-start) {
446 -webkit-box-pack: start;
447 -ms-flex-pack: start;
448 -moz-justify-content: flex-start;
449 -webkit-justify-content: flex-start;
450 justify-content: flex-start;
453 :host(.core-justify-center) {
454 -webkit-box-pack: center;
455 -ms-flex-pack: center;
456 -moz-justify-content: center;
457 -webkit-justify-content: center;
458 justify-content: center;
461 :host(.core-justify-end) {
462 -webkit-box-pack: end;
464 -moz-justify-content: flex-end;
465 -webkit-justify-content: flex-end;
466 justify-content: flex-end;
469 :host(.core-justify-between) {
470 -webkit-box-pack: justify;
471 -ms-flex-pack: justify;
472 -moz-justify-content: space-between;
473 -webkit-justify-content: space-between;
474 justify-content: space-between;
477 /* alignment in cross axis */
478 :host(.core-align-start) {
479 -webkit-box-align: start;
480 -ms-flex-align: start;
481 -moz-align-items: flex-start;
482 -webkit-align-items: flex-start;
483 align-items: flex-start;
486 :host(.core-align-center) {
487 -webkit-box-align: center;
488 -ms-flex-align: center;
489 -moz-align-items: center;
490 -webkit-align-items: center;
494 :host(.core-align-end) {
495 -webkit-box-align: end;
497 -moz-align-items: flex-end;
498 -webkit-align-items: flex-end;
499 align-items: flex-end;
509 Polymer('core-layout', {
513 * Controls if the element lays out vertically or not.
515 * @attribute vertical
521 * Controls how the items are aligned in the main-axis direction. For
522 * example for a horizontal layout, this controls how each item is aligned
526 * @type string start|center|end|between
531 * Controls how the items are aligned in cross-axis direction. For
532 * example for a horizontal layout, this controls how each item is aligned
536 * @type string start|center|end
541 * Controls whether or not the items layout in reverse order.
548 layoutPrefix
: 'core-',
550 // NOTE: include template so that styles are loaded, but remove
551 // so that we can decide dynamically what part to include
552 registerCallback: function(polymerElement
) {
553 var template
= polymerElement
.querySelector('template');
554 this.styles
= template
.content
.querySelectorAll('style').array();
555 this.styles
.forEach(function(s
) {
556 s
.removeAttribute('no-shim');
560 fetchTemplate: function() {
564 attached: function() {
565 this.installScopeStyle(this.styles
[0]);
566 if (this.children
.length
) {
567 this.isContainer
= true;
569 var container
= this.isContainer
? this : this.parentNode
;
570 // detect if laying out a shadowRoot host.
571 var forHost
= container
instanceof ShadowRoot
;
573 this.installScopeStyle(this.styles
[1], 'host');
574 container
= container
.host
|| document
.body
;
576 this.layoutContainer
= container
;
579 detached: function() {
580 this.layoutContainer
= null;
583 layoutContainerChanged: function(old
) {
584 this.style
.display
= this.layoutContainer
=== this ? null : 'none';
585 this.verticalChanged();
587 this.justifyChanged();
590 setLayoutClass: function(prefix
, old
, newValue
) {
591 if (this.layoutContainer
) {
592 prefix
= this.layoutPrefix
+ prefix
;
594 this.layoutContainer
.classList
.remove(prefix
+ old
);
597 this.layoutContainer
.classList
.add(prefix
+ newValue
);
602 verticalChanged: function(old
) {
603 old
= old
? 'v' : 'h';
604 var vertical
= this.vertical
? 'v' : 'h';
605 this.setLayoutClass('', old
, vertical
);
608 alignChanged: function(old
) {
609 this.setLayoutClass('align-', old
, this.align
);
612 justifyChanged: function(old
) {
613 this.setLayoutClass('justify-', old
, this.justify
);
616 reverseChanged: function(old
) {
617 old
= old
? 'reverse' : '';
618 var newValue
= this.reverse
? 'reverse' : '';
619 this.setLayoutClass('', old
, newValue
);
631 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
632 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
633 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
634 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
635 Code distributed by Google as part of the polymer project is also
636 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
639 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
640 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
641 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
642 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
643 Code distributed by Google as part of the polymer project is also
644 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
648 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
649 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
650 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
651 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
652 Code distributed by Google as part of the polymer project is also
653 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
658 * @group Polymer Core Elements
660 * The `core-iconset-svg` element allows users to define their own icon sets
661 * that contain svg icons. The svg icon elements should be children of the
662 * `core-iconset-svg` element. Multiple icons should be given distinct id's.
664 * Using svg elements to create icons has a few advantages over traditional
665 * bitmap graphics like jpg or png. Icons that use svg are vector based so they
666 * are resolution independent and should look good on any device. They are
667 * stylable via css. Icons can be themed, colorized, and even animated.
671 * <core-iconset-svg id="my-svg-icons" iconSize="24">
675 * <rect x="50" y="50" width="50" height="50" />
676 * <circle cx="50" cy="50" r="50" />
680 * </core-iconset-svg>
682 * This will automatically register the icon set "my-svg-icons" to the iconset
683 * database. To use these icons from within another element, make a
684 * `core-iconset` element and call the `byId` method
685 * to retrieve a given iconset. To apply a particular icon inside an
686 * element use the `applyIcon` method. For example:
688 * iconset.applyIcon(iconNode, 'car');
690 * @element core-iconset-svg
692 * @homepage github.io
697 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
698 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
699 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
700 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
701 Code distributed by Google as part of the polymer project is also
702 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
707 * @group Polymer Core Elements
709 * The `core-iconset` element allows users to define their own icon sets.
710 * The `src` property specifies the url of the icon image. Multiple icons may
711 * be included in this image and they may be organized into rows.
712 * The `icons` property is a space separated list of names corresponding to the
713 * icons. The names must be ordered as the icons are ordered in the icon image.
714 * Icons are expected to be square and are the size specified by the `iconSize`
715 * property. The `width` property corresponds to the width of the icon image
716 * and must be specified if icons are arranged into multiple rows in the image.
718 * All `core-iconset` elements are available for use by other `core-iconset`
719 * elements via a database keyed by id. Typically, an element author that wants
720 * to support a set of custom icons uses a `core-iconset` to retrieve
721 * and use another, user-defined iconset.
725 * <core-iconset id="my-icons" src="my-icons.png" width="96" iconSize="24"
726 * icons="location place starta stopb bus car train walk">
729 * This will automatically register the icon set "my-icons" to the iconset
730 * database. To use these icons from within another element, make a
731 * `core-iconset` element and call the `byId` method to retrieve a
732 * given iconset. To apply a particular icon to an element, use the
733 * `applyIcon` method. For example:
735 * iconset.applyIcon(iconNode, 'car');
737 * Themed icon sets are also supported. The `core-iconset` can contain child
738 * `property` elements that specify a theme with an offsetX and offsetY of the
739 * theme within the icon resource. For example.
741 * <core-iconset id="my-icons" src="my-icons.png" width="96" iconSize="24"
742 * icons="location place starta stopb bus car train walk">
743 * <property theme="special" offsetX="256" offsetY="24"></property>
746 * Then a themed icon can be applied like this:
748 * iconset.applyIcon(iconNode, 'car', 'special');
750 * @element core-iconset
752 * @homepage github.io
757 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
758 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
759 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
760 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
761 Code distributed by Google as part of the polymer project is also
762 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
766 `core-meta` provides a method of constructing a self-organizing database.
767 It is useful to collate element meta-data for things like catalogs and for
770 Example, an element folder has a `metadata.html` file in it, that contains a
771 `core-meta`, something like this:
773 <core-meta id="my-element" label="My Element">
774 <property name="color" value="blue"></property>
777 An application can import as many of these files as it wants, and then use
778 `core-meta` again to access the collected data.
781 var meta = document.createElement('core-meta');
782 console.log(meta.list); // dump a list of all meta-data elements that have been created
785 Use `byId(id)` to retrive a specific core-meta.
788 var meta = document.createElement('core-meta');
789 console.log(meta.byId('my-element'));
792 By default all meta-data are stored in a single databse. If your meta-data
793 have different types and want them to be stored separately, use `type` to
798 <core-meta id="x-foo" type="xElt"></core-meta>
799 <core-meta id="x-bar" type="xElt"></core-meta>
800 <core-meta id="y-bar" type="yElt"></core-meta>
803 var meta = document.createElement('core-meta');
805 console.log(meta.list);
808 @group Polymer Core Elements
815 <polymer-element name="core-meta" attributes="list label type" hidden assetpath="../core-meta/">
820 var SKIP_ID = 'meta';
821 var metaData = {}, metaArray = {};
823 Polymer('core-meta', {
826 * The type of meta-data. All meta-data with the same type with be
838 this.register(this.id);
857 register: function(id, old) {
858 if (id && id !== SKIP_ID) {
859 this.unregister(this, old);
860 this.metaData[id] = this;
861 this.metaArray.push(this);
865 unregister: function(meta, id) {
866 delete this.metaData[id || meta.id];
867 var i = this.metaArray.indexOf(meta);
869 this.metaArray.splice(i, 1);
874 * Returns a list of all meta-data elements with the same type.
881 return this.metaArray;
885 * Retrieves meta-data by ID.
888 * @param {String} id The ID of the meta-data to be returned.
889 * @returns Returns meta-data.
892 return this.metaData[id];
903 <polymer-element name="core-iconset" extends="core-meta" attributes="src width icons iconSize" assetpath="../core-iconset/">
907 Polymer('core-iconset', {
910 * The URL of the iconset image.
919 * The width of the iconset image. This must only be specified if the
920 * icons are arranged into separate rows inside the image.
929 * A space separated list of names corresponding to icons in the iconset
930 * image file. This list must be ordered the same as the icon images
940 * The size of an individual icon. Note that icons must be square.
942 * @attribute iconSize
949 * The horizontal offset of the icon images in the inconset src image.
950 * This is typically used if the image resource contains additional images
951 * beside those intended for the iconset.
959 * The vertical offset of the icon images in the inconset src image.
960 * This is typically used if the image resource contains additional images
961 * beside those intended for the iconset.
970 created: function() {
977 // TODO(sorvell): ensure iconset's src is always relative to the main
979 if (this.src && (this.ownerDocument !== document)) {
980 this.src = this.resolvePath(this.src, this.ownerDocument.baseURI);
986 iconsChanged: function() {
987 var ox = this.offsetX;
988 var oy = this.offsetY;
989 this.icons && this.icons.split(/\s+/g).forEach(function(name, i) {
990 this.iconNames.push(name);
991 this.iconMap[name] = {
995 if (ox + this.iconSize < this.width) {
1004 updateThemes: function() {
1005 var ts = this.querySelectorAll('property[theme]');
1006 ts && ts.array().forEach(function(t) {
1007 this.themes[t.getAttribute('theme')] = {
1008 offsetX: parseInt(t.getAttribute('offsetX')) || 0,
1009 offsetY: parseInt(t.getAttribute('offsetY')) || 0
1014 // TODO(ffu): support retrived by index e.g. getOffset(10);
1016 * Returns an object containing `offsetX` and `offsetY` properties which
1017 * specify the pixel locaion in the iconset's src file for the given
1018 * `icon` and `theme`. It's uncommon to call this method. It is useful,
1019 * for example, to manually position a css backgroundImage to the proper
1020 * offset. It's more common to use the `applyIcon` method.
1023 * @param {String|Number} icon The name of the icon or the index of the
1024 * icon within in the icon image.
1025 * @param {String} theme The name of the theme.
1026 * @returns {Object} An object specifying the offset of the given icon
1027 * within the icon resource file; `offsetX` is the horizontal offset and
1028 * `offsetY` is the vertical offset. Both values are in pixel units.
1030 getOffset: function(icon, theme) {
1031 var i = this.iconMap[icon];
1033 var n = this.iconNames[Number(icon)];
1034 i = this.iconMap[n];
1036 var t = this.themes[theme];
1039 offsetX: i.offsetX + t.offsetX,
1040 offsetY: i.offsetY + t.offsetY
1047 * Applies an icon to the given element as a css background image. This
1048 * method does not size the element, and it's often necessary to set
1049 * the element's height and width so that the background image is visible.
1052 * @param {Element} element The element to which the background is
1054 * @param {String|Number} icon The name or index of the icon to apply.
1055 * @param {String} theme (optional) The name of the theme for the icon.
1056 * @param {Number} scale (optional, defaults to 1) A scaling factor
1057 * with which the icon can be magnified.
1059 applyIcon: function(element, icon, scale) {
1060 var offset = this.getOffset(icon);
1062 if (element && offset) {
1063 var style = element.style;
1064 style.backgroundImage = 'url(' + this.src + ')';
1065 style.backgroundPosition = (-offset.offsetX * scale + 'px') +
1066 ' ' + (-offset.offsetY * scale + 'px');
1067 style.backgroundSize = scale === 1 ? 'auto' :
1068 this.width * scale + 'px';
1079 <polymer-element name="core-iconset-svg" extends="core-meta" attributes="iconSize" assetpath="../core-iconset-svg/">
1083 Polymer('core-iconset-svg', {
1087 * The size of an individual icon. Note that icons must be square.
1089 * @attribute iconSize
1096 created: function() {
1105 iconById: function(id) {
1106 return this._icons[id] || (this._icons[id] = this.querySelector('#' + id));
1109 cloneIcon: function(id) {
1110 var icon = this.iconById(id);
1112 var content = icon.cloneNode(true);
1113 var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1114 svg.setAttribute('viewBox', '0 0 ' + this.iconSize + ' ' +
1116 // NOTE(dfreedm): work around https://crbug.com/370136
1117 svg.style.pointerEvents = 'none';
1118 svg.appendChild(content);
1124 if (!this._iconNames) {
1125 this._iconNames = this.findIconNames();
1127 return this._iconNames;
1130 findIconNames: function() {
1131 var icons = this.querySelectorAll('[id]').array();
1133 return icons.map(function(n){ return n.id });
1138 * Applies an icon to the given element. The svg icon is added to the
1139 * element's shadowRoot if one exists or directly to itself.
1142 * @param {Element} element The element to which the icon is
1144 * @param {String|Number} icon The name the icon to apply.
1146 applyIcon: function(element, icon, scale) {
1147 var root = element.shadowRoot || element;
1149 var old = root.querySelector('svg');
1154 var svg = this.cloneIcon(icon);
1158 var size = scale * this.iconSize;
1160 svg.style.height = svg.style.width = size + 'px';
1162 svg.setAttribute('height', '100%');
1163 svg.setAttribute('width', '100%');
1164 svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
1166 svg.style.display = 'block';
1167 root.insertBefore(svg, root.firstElementChild);
1171 * Tell users of the iconset, that the set has loaded.
1172 * This finds all elements matching the selector argument and calls
1173 * the method argument on them.
1174 * @method updateIcons
1175 * @param selector {string} css selector to identify iconset users,
1176 * defaults to '[icon]'
1177 * @param method {string} method to call on found elements,
1178 * defaults to 'updateIcon'
1180 updateIcons: function(selector, method) {
1181 selector = selector || '[icon]';
1182 method = method || 'updateIcon';
1183 var deep = window.ShadowDOMPolyfill ? '' : 'html /deep/ ';
1184 var i$ = document.querySelectorAll(deep + selector);
1185 for (var i=0, e; e=i$[i]; i++) {
1199 <core-iconset-svg id="icons" iconsize="24">
1201 <g id="accessibility"><path d="M12,2c1.1,0,2,0.9,2,2s-0.9,2-2,2s-2-0.9-2-2S10.9,2,12,2z M21,9h-6v13h-2v-6h-2v6H9V9H3V7h18V9z"></path></g>
1202 <g id="account-box"><path d="M3,5l0,14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2H5C3.9,3,3,3.9,3,5z M15,9c0,1.7-1.3,3-3,3c-1.7,0-3-1.3-3-3c0-1.7,1.3-3,3-3C13.7,6,15,7.3,15,9z M6,17c0-2,4-3.1,6-3.1s6,1.1,6,3.1v1H6V17z"></path></g>
1203 <g id="account-circle"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,5c1.7,0,3,1.3,3,3c0,1.7-1.3,3-3,3c-1.7,0-3-1.3-3-3C9,6.3,10.3,5,12,5z M12,19.2c-2.5,0-4.7-1.3-6-3.2c0-2,4-3.1,6-3.1c2,0,6,1.1,6,3.1C16.7,17.9,14.5,19.2,12,19.2z"></path></g>
1204 <g id="add"><path d="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6V13z"></path></g>
1205 <g id="add-box"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17,13h-4v4h-2v-4H7v-2h4V7h2v4h4V13z"></path></g>
1206 <g id="add-circle"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M17,13h-4v4h-2v-4H7v-2h4V7h2v4h4V13z"></path></g>
1207 <g id="add-circle-outline"><path d="M13,7h-2v4H7v2h4v4h2v-4h4v-2h-4V7z M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z"></path></g>
1208 <g id="android"><path d="M6,18c0,0.6,0.4,1,1,1h1v3.5C8,23.3,8.7,24,9.5,24c0.8,0,1.5-0.7,1.5-1.5V19h2v3.5c0,0.8,0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5V19h1c0.6,0,1-0.4,1-1V8H6V18z M3.5,8C2.7,8,2,8.7,2,9.5v7C2,17.3,2.7,18,3.5,18C4.3,18,5,17.3,5,16.5v-7C5,8.7,4.3,8,3.5,8z M20.5,8C19.7,8,19,8.7,19,9.5v7c0,0.8,0.7,1.5,1.5,1.5c0.8,0,1.5-0.7,1.5-1.5v-7C22,8.7,21.3,8,20.5,8z M15.5,2.2l1.3-1.3c0.2-0.2,0.2-0.5,0-0.7c-0.2-0.2-0.5-0.2-0.7,0l-1.5,1.5C13.9,1.2,13,1,12,1c-1,0-1.9,0.2-2.7,0.6L7.9,0.1C7.7,0,7.3,0,7.1,0.1C7,0.3,7,0.7,7.1,0.9l1.3,1.3C7,3.3,6,5,6,7h12C18,5,17,3.2,15.5,2.2z M10,5H9V4h1V5z M15,5h-1V4h1V5z"></path></g>
1209 <g id="apps"><path d="M4,8h4V4H4V8z M10,20h4v-4h-4V20z M4,20h4v-4H4V20z M4,14h4v-4H4V14z M10,14h4v-4h-4V14z M16,4v4h4V4H16z M10,8h4V4h-4V8z M16,14h4v-4h-4V14z M16,20h4v-4h-4V20z"></path></g>
1210 <g id="archive"><path d="M20.5,5.2l-1.4-1.7C18.9,3.2,18.5,3,18,3H6C5.5,3,5.1,3.2,4.8,3.5L3.5,5.2C3.2,5.6,3,6,3,6.5V19c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V6.5C21,6,20.8,5.6,20.5,5.2z M12,17.5L6.5,12H10v-2h4v2h3.5L12,17.5z M5.1,5l0.8-1h12l0.9,1H5.1z"></path></g>
1211 <g id="arrow-back"><path d="M20,11H7.8l5.6-5.6L12,4l-8,8l8,8l1.4-1.4L7.8,13H20V11z"></path></g>
1212 <g id="arrow-drop-down"><polygon points="7,10 12,15 17,10 "></polygon></g>
1213 <g id="arrow-drop-down-circle"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,14l-4-4h8L12,14z"></path></g>
1214 <g id="arrow-drop-up"><polygon points="7,14 12,9 17,14 "></polygon></g>
1215 <g id="arrow-forward"><polygon points="12,4 10.6,5.4 16.2,11 4,11 4,13 16.2,13 10.6,18.6 12,20 20,12 "></polygon></g>
1216 <g id="attachment"><path d="M7.5,18c-3,0-5.5-2.5-5.5-5.5S4.5,7,7.5,7H18c2.2,0,4,1.8,4,4s-1.8,4-4,4H9.5C8.1,15,7,13.9,7,12.5S8.1,10,9.5,10H17v1.5H9.5c-0.6,0-1,0.4-1,1s0.4,1,1,1H18c1.4,0,2.5-1.1,2.5-2.5S19.4,8.5,18,8.5H7.5c-2.2,0-4,1.8-4,4s1.8,4,4,4H17V18H7.5z"></path></g>
1217 <g id="backspace"><path d="M22,3H7C6.3,3,5.8,3.3,5.4,3.9L0,12l5.4,8.1C5.8,20.6,6.3,21,7,21h15c1.1,0,2-0.9,2-2V5C24,3.9,23.1,3,22,3z M19,15.6L17.6,17L14,13.4L10.4,17L9,15.6l3.6-3.6L9,8.4L10.4,7l3.6,3.6L17.6,7L19,8.4L15.4,12L19,15.6z"></path></g>
1218 <g id="backup"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6C9.1,4,6.6,5.6,5.4,8C2.3,8.4,0,10.9,0,14c0,3.3,2.7,6,6,6h13c2.8,0,5-2.2,5-5C24,12.4,21.9,10.2,19.4,10z M14,13v4h-4v-4H7l5-5l5,5H14z"></path></g>
1219 <g id="block"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M4,12c0-4.4,3.6-8,8-8c1.8,0,3.5,0.6,4.9,1.7L5.7,16.9C4.6,15.5,4,13.8,4,12z M12,20c-1.8,0-3.5-0.6-4.9-1.7L18.3,7.1C19.4,8.5,20,10.2,20,12C20,16.4,16.4,20,12,20z"></path></g>
1220 <g id="book"><path d="M18,22c1.1,0,2-0.9,2-2V4c0-1.1-0.9-2-2-2h-6v7L9.5,7.5L7,9V2H6C4.9,2,4,2.9,4,4v16c0,1.1,0.9,2,2,2H18z"></path></g>
1221 <g id="bookmark"><path d="M17,3H7C5.9,3,5,3.9,5,5l0,16l7-3l7,3V5C19,3.9,18.1,3,17,3z"></path></g>
1222 <g id="bookmark-outline"><path d="M17,3H7C5.9,3,5,3.9,5,5l0,16l7-3l7,3V5C19,3.9,18.1,3,17,3z M17,18l-5-2.2L7,18V5h10V18z"></path></g>
1223 <g id="bug-report"><path d="M20,8h-2.8c-0.5-0.8-1.1-1.5-1.8-2L17,4.4L15.6,3l-2.2,2.2C13,5.1,12.5,5,12,5s-1,0.1-1.4,0.2L8.4,3L7,4.4L8.6,6C7.9,6.5,7.3,7.2,6.8,8H4v2h2.1C6,10.3,6,10.7,6,11v1H4v2h2v1c0,0.3,0,0.7,0.1,1H4v2h2.8c1,1.8,3,3,5.2,3s4.2-1.2,5.2-3H20v-2h-2.1c0.1-0.3,0.1-0.7,0.1-1v-1h2v-2h-2v-1c0-0.3,0-0.7-0.1-1H20V8z M14,16h-4v-2h4V16z M14,12h-4v-2h4V12z"></path></g>
1224 <g id="cancel"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M17,15.6L15.6,17L12,13.4L8.4,17L7,15.6l3.6-3.6L7,8.4L8.4,7l3.6,3.6L15.6,7L17,8.4L13.4,12L17,15.6z"></path></g>
1225 <g id="check"><polygon points="9,16.2 4.8,12 3.4,13.4 9,19 21,7 19.6,5.6 "></polygon></g>
1226 <g id="check-box"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M10,17l-5-5l1.4-1.4l3.6,3.6l7.6-7.6L19,8L10,17z"></path></g>
1227 <g id="check-box-blank"><path d="M19,3H5C3.9,3,3,3.9,3,5l0,14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z"></path></g>
1228 <g id="check-box-outline"><path d="M7.9,10.1l-1.4,1.4L11,16L21,6l-1.4-1.4L11,13.2L7.9,10.1z M19,19L5,19V5h10V3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2v-8h-2V19z"></path></g>
1229 <g id="check-box-outline-blank"><path d="M19,5v14L5,19V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z"></path></g>
1230 <g id="check-circle"><path d="M12,2C6.5,2,2,6.5,2,12c0,5.5,4.5,10,10,10c5.5,0,10-4.5,10-10C22,6.5,17.5,2,12,2z M10,17l-5-5l1.4-1.4l3.6,3.6l7.6-7.6L19,8L10,17z"></path></g>
1231 <g id="check-circle-blank"><path d="M12,2C6.5,2,2,6.5,2,12c0,5.5,4.5,10,10,10c5.5,0,10-4.5,10-10C22,6.5,17.5,2,12,2z"></path></g>
1232 <g id="check-circle-outline"><path d="M7.9,10.1l-1.4,1.4L11,16L21,6l-1.4-1.4L11,13.2L7.9,10.1z M20,12c0,4.4-3.6,8-8,8s-8-3.6-8-8s3.6-8,8-8c0.8,0,1.5,0.1,2.2,0.3l1.6-1.6C14.6,2.3,13.3,2,12,2C6.5,2,2,6.5,2,12s4.5,10,10,10s10-4.5,10-10H20z"></path></g>
1233 <g id="check-circle-outline-blank"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z"></path></g>
1234 <g id="chevron-left"><polygon points="15.4,7.4 14,6 8,12 14,18 15.4,16.6 10.8,12 "></polygon></g>
1235 <g id="chevron-right"><polygon points="10,6 8.6,7.4 13.2,12 8.6,16.6 10,18 16,12 "></polygon></g>
1236 <g id="clear"><polygon points="19,6.4 17.6,5 12,10.6 6.4,5 5,6.4 10.6,12 5,17.6 6.4,19 12,13.4 17.6,19 19,17.6 13.4,12 "></polygon></g>
1237 <g id="close"><polygon points="19,6.4 17.6,5 12,10.6 6.4,5 5,6.4 10.6,12 5,17.6 6.4,19 12,13.4 17.6,19 19,17.6 13.4,12 "></polygon></g>
1238 <g id="cloud"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6C9.1,4,6.6,5.6,5.4,8C2.3,8.4,0,10.9,0,14c0,3.3,2.7,6,6,6h13c2.8,0,5-2.2,5-5C24,12.4,21.9,10.2,19.4,10z"></path></g>
1239 <g id="cloud-circle"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M17,15H8H7.5C6.1,15,5,13.9,5,12.5S6.1,10,7.5,10h0.6c0.4-1.7,2-3,3.9-3c2.2,0,4,1.8,4,4h1c1.1,0,2,0.9,2,2S18.1,15,17,15z"></path></g>
1240 <g id="cloud-done"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6C9.1,4,6.6,5.6,5.4,8C2.3,8.4,0,10.9,0,14c0,3.3,2.7,6,6,6h13c2.8,0,5-2.2,5-5C24,12.4,21.9,10.2,19.4,10z M10,17l-3.5-3.5l1.4-1.4l2.1,2.1L15.2,9l1.4,1.4L10,17z"></path></g>
1241 <g id="cloud-download"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6C9.1,4,6.6,5.6,5.4,8C2.3,8.4,0,10.9,0,14c0,3.3,2.7,6,6,6h13c2.8,0,5-2.2,5-5C24,12.4,21.9,10.2,19.4,10z M17,13l-5,5l-5-5h3V9h4v4H17z"></path></g>
1242 <g id="cloud-off"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6c-1.5,0-2.9,0.4-4,1.2l1.5,1.5C10.2,6.2,11.1,6,12,6c3,0,5.5,2.5,5.5,5.5V12H19c1.7,0,3,1.3,3,3c0,1.1-0.6,2.1-1.6,2.6l1.5,1.5c1.3-0.9,2.1-2.4,2.1-4.1C24,12.4,21.9,10.2,19.4,10z M3,5.3L5.8,8C2.6,8.2,0,10.8,0,14c0,3.3,2.7,6,6,6h11.7l2,2l1.3-1.3L4.3,4L3,5.3z M7.7,10l8,8H6c-2.2,0-4-1.8-4-4c0-2.2,1.8-4,4-4H7.7z"></path></g>
1243 <g id="cloud-queue"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6C9.1,4,6.6,5.6,5.4,8C2.3,8.4,0,10.9,0,14c0,3.3,2.7,6,6,6h13c2.8,0,5-2.2,5-5C24,12.4,21.9,10.2,19.4,10z M19,18H6c-2.2,0-4-1.8-4-4c0-2.2,1.8-4,4-4h0.7C7.4,7.7,9.5,6,12,6c3,0,5.5,2.5,5.5,5.5V12H19c1.7,0,3,1.3,3,3S20.7,18,19,18z"></path></g>
1244 <g id="cloud-upload"><path d="M19.4,10c-0.7-3.4-3.7-6-7.4-6C9.1,4,6.6,5.6,5.4,8C2.3,8.4,0,10.9,0,14c0,3.3,2.7,6,6,6h13c2.8,0,5-2.2,5-5C24,12.4,21.9,10.2,19.4,10z M14,13v4h-4v-4H7l5-5l5,5H14z"></path></g>
1245 <g id="content-copy"><path d="M16,1H4C2.9,1,2,1.9,2,3v14h2V3h12V1z M19,5H8C6.9,5,6,5.9,6,7v14c0,1.1,0.9,2,2,2h11c1.1,0,2-0.9,2-2V7C21,5.9,20.1,5,19,5z M19,21H8V7h11V21z"></path></g>
1246 <g id="content-cut"><path d="M10,6c0-2.2-1.8-4-4-4S2,3.8,2,6c0,2.2,1.8,4,4,4c0.6,0,1.1-0.1,1.6-0.4L10,12l-2.4,2.4C7.1,14.1,6.6,14,6,14c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4s4-1.8,4-4c0-0.6-0.1-1.1-0.4-1.6L12,14l7,7h4L9.6,7.6C9.9,7.1,10,6.6,10,6z M6,8C4.9,8,4,7.1,4,6s0.9-2,2-2c1.1,0,2,0.9,2,2S7.1,8,6,8z M6,20c-1.1,0-2-0.9-2-2s0.9-2,2-2c1.1,0,2,0.9,2,2S7.1,20,6,20z M12,11.5c0.3,0,0.5,0.2,0.5,0.5c0,0.3-0.2,0.5-0.5,0.5c-0.3,0-0.5-0.2-0.5-0.5C11.5,11.7,11.7,11.5,12,11.5z M23,3h-4l-6,6l2,2L23,3z"></path></g>
1247 <g id="content-paste"><path d="M19,2h-4.2c-0.4-1.2-1.5-2-2.8-2c-1.3,0-2.4,0.8-2.8,2H5C3.9,2,3,2.9,3,4v16c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V4C21,2.9,20.1,2,19,2z M12,2c0.6,0,1,0.4,1,1s-0.4,1-1,1c-0.6,0-1-0.4-1-1S11.4,2,12,2z M19,20H5V4h2v3h10V4h2V20z"></path></g>
1248 <g id="create"><path d="M3,17.2V21h3.8L17.8,9.9l-3.8-3.8L3,17.2z M20.7,7c0.4-0.4,0.4-1,0-1.4l-2.3-2.3c-0.4-0.4-1-0.4-1.4,0l-1.8,1.8l3.8,3.8L20.7,7z"></path></g>
1249 <g id="credit-card"><path d="M20,4H4C2.9,4,2,4.9,2,6v12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V6C22,4.9,21.1,4,20,4z M20,18H4v-6h16V18z M20,8H4V6h16V8z"></path></g>
1250 <g id="delete"><path d="M6,19c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2V7H6V19z M19,4h-3.5l-1-1h-5l-1,1H5v2h14V4z"></path></g>
1251 <g id="done"><polygon points="9,16.2 4.8,12 3.4,13.4 9,19 21,7 19.6,5.6 "></polygon></g>
1252 <g id="done-all"><path d="M18,7l-1.4-1.4l-6.3,6.3l1.4,1.4L18,7z M22.2,5.6L11.7,16.2L7.5,12l-1.4,1.4l5.6,5.6l12-12L22.2,5.6z M0.4,13.4L6,19l1.4-1.4L1.8,12L0.4,13.4z"></path></g>
1253 <g id="drafts"><path d="M22,8c0-0.7-0.4-1.3-0.9-1.7L12,1L2.9,6.3C2.4,6.7,2,7.3,2,8v10c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2L22,8z M12,13L3.7,7.8L12,3l8.3,4.8L12,13z"></path></g>
1254 <g id="drive"><path d="M22.3,14L15.4,2H8.6l0,0l6.9,12H22.3z M9.7,15l-3.4,6h13.1l3.4-6H9.7z M7.7,3.5L1.2,15l3.4,6l6.6-11.5L7.7,3.5z"></path></g>
1255 <g id="drawer"><path d="M20,4H4C2.8,4,2,4.8,2,6v12c0,1.2,0.8,2,2,2h16c1,0,2-0.8,2-2V6C22,4.8,21,4,20,4z M20,18h-6V6h6V18z"></path></g>
1256 <g id="drive-document"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17,9H7V7h10V9z M17,13H7v-2h10V13z M14,17H7v-2h7V17z"></path></g>
1257 <g id="drive-drawing"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M18,18h-6v-5.8c-0.7,0.6-1.5,1-2.5,1c-2,0-3.7-1.7-3.7-3.7s1.7-3.7,3.7-3.7c2,0,3.7,1.7,3.7,3.7c0,1-0.4,1.8-1,2.5H18V18z"></path></g>
1258 <g id="drive-file"><path d="M6,2C4.9,2,4,2.9,4,4l0,16c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V8l-6-6H6z M13,9V3.5L18.5,9H13z"></path></g>
1259 <g id="drive-form"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M9,17H7v-2h2V17z M9,13H7v-2h2V13z M9,9H7V7h2V9z M17,17h-7v-2h7V17z M17,13h-7v-2h7V13z M17,9h-7V7h7V9z"></path></g>
1260 <g id="drive-fusiontable"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,10.2L13,17l-4-4l-4,4v-3l4-4l4,4l6-6.8V10.2z"></path></g>
1261 <g id="drive-image"><path d="M21,19V5c0-1.1-0.9-2-2-2H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14C20.1,21,21,20.1,21,19z M8.5,13.5l2.5,3l3.5-4.5l4.5,6H5L8.5,13.5z"></path></g>
1262 <g id="drive-ms-excel"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M16.2,17h-2L12,13.2L9.8,17h-2l3.2-5L7.8,7h2l2.2,3.8L14.2,7h2L13,12L16.2,17z"></path></g>
1263 <g id="drive-ms-powerpoint"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M9.8,13.4V17H8V7h4.3c1.5,0,2.2,0.3,2.8,0.9c0.7,0.6,0.9,1.4,0.9,2.3c0,1-0.3,1.8-0.9,2.3c-0.6,0.5-1.3,0.8-2.8,0.8H9.8z"></path><path d="M9.8,12V8.4h2.3c0.7,0,1.2,0.2,1.5,0.6c0.3,0.4,0.5,0.7,0.5,1.2c0,0.6-0.2,0.9-0.5,1.3c-0.3,0.3-0.7,0.5-1.4,0.5H9.8z"></path></g>
1264 <g id="drive-ms-word"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M15.5,17H14l-2-7.5L10,17H8.5L6.1,7h1.7l1.5,7.5l2-7.5h1.4l2,7.5L16.2,7h1.7L15.5,17z"></path></g>
1265 <g id="drive-pdf"><path d="M11.3,8.6L11.3,8.6C11.4,8.6,11.4,8.6,11.3,8.6c0.1-0.4,0.2-0.6,0.2-0.9l0-0.2c0.1-0.5,0.1-0.9,0-1c0,0,0,0,0-0.1l-0.1-0.1c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0.1-0.1,0.1C11.1,7,11.1,7.7,11.3,8.6C11.3,8.6,11.3,8.6,11.3,8.6z M8.3,15.5c-0.2,0.1-0.4,0.2-0.5,0.3c-0.7,0.6-1.2,1.3-1.3,1.6c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0C7.1,17.3,7.7,16.7,8.3,15.5C8.4,15.5,8.4,15.5,8.3,15.5C8.4,15.5,8.3,15.5,8.3,15.5z M17.5,14c-0.1-0.1-0.5-0.4-1.9-0.4c-0.1,0-0.1,0-0.2,0c0,0,0,0,0,0c0,0,0,0,0,0.1c0.7,0.3,1.4,0.5,1.9,0.5c0.1,0,0.1,0,0.2,0l0,0c0,0,0.1,0,0.1,0c0,0,0,0,0-0.1c0,0,0,0,0,0C17.6,14.1,17.5,14.1,17.5,14z M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17.9,14.8C17.7,14.9,17.4,15,17,15c-0.8,0-2-0.2-3-0.7c-1.7,0.2-3,0.4-4,0.8c-0.1,0-0.1,0-0.2,0.1c-1.2,2.1-2.2,3.1-3,3.1c-0.2,0-0.3,0-0.4-0.1l-0.5-0.3l0-0.1c-0.1-0.2-0.1-0.3-0.1-0.5c0.1-0.5,0.7-1.4,1.9-2.1c0.2-0.1,0.5-0.3,0.9-0.5c0.3-0.5,0.6-1.1,1-1.8c0.5-1,0.8-2,1.1-2.9l0,0c-0.4-1.2-0.6-1.9-0.2-3.3c0.1-0.4,0.4-0.8,0.8-0.8l0.2,0c0.2,0,0.4,0.1,0.6,0.2c0.7,0.7,0.4,2.3,0,3.6c0,0.1,0,0.1,0,0.1c0.4,1.1,1,2,1.6,2.6c0.3,0.2,0.5,0.4,0.9,0.6c0.5,0,0.9-0.1,1.3-0.1c1.2,0,2,0.2,2.3,0.7c0.1,0.2,0.1,0.4,0.1,0.6C18.2,14.3,18.1,14.6,17.9,14.8z M11.4,10.9c-0.2,0.7-0.6,1.5-1,2.4c-0.2,0.4-0.4,0.7-0.6,1.1c0,0,0.1,0,0.1,0l0.1,0v0c1.3-0.5,2.5-0.8,3.3-0.9c-0.2-0.1-0.3-0.2-0.4-0.3C12.4,12.6,11.8,11.8,11.4,10.9z"></path></g>
1266 <g id="drive-presentation"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,16H5V8h14V16z"></path></g>
1267 <g id="drive-script"><path d="M19,3H5C3.9,3,3,3.9,3,5l0,4h0v6h0l0,4c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M11,17v-3H5v-4h6V7l5,5L11,17z"></path></g>
1268 <g id="drive-site"><path d="M19,4H5C3.9,4,3,4.9,3,6l0,12c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V6C21,4.9,20.1,4,19,4z M14,18H5v-4h9V18z M14,13H5V9h9V13z M19,18h-4V9h4V18z"></path></g>
1269 <g id="drive-spreadsheet"><path d="M19,3H5C3.9,3,3,3.9,3,5l0,3h0v11c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,11h-8v8H9v-8H5V9h4V5h2v4h8V11z"></path></g>
1270 <g id="drive-video"><path d="M18,4l2,4h-3l-2-4h-2l2,4h-3l-2-4H8l2,4H7L5,4H4C2.9,4,2,4.9,2,6l0,12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V4H18z"></path></g>
1271 <g id="error"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M13,17h-2v-2h2V17z M13,13h-2V7h2V13z"></path></g>
1272 <g id="event"><path d="M17,12h-5v5h5V12z M16,1v2H8V1H6v2H5C3.9,3,3,3.9,3,5l0,14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-1V1H16z M19,19H5V8h14V19z"></path></g>
1273 <g id="exit-to-app"><path d="M10.1,15.6l1.4,1.4l5-5l-5-5l-1.4,1.4l2.6,2.6H3v2h9.7L10.1,15.6z M19,3H5C3.9,3,3,3.9,3,5v4h2V5h14v14H5v-4H3v4c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z"></path></g>
1274 <g id="expand-less"><polygon points="12,8 6,14 7.4,15.4 12,10.8 16.6,15.4 18,14 "></polygon></g>
1275 <g id="expand-more"><polygon points="16.6,8.6 12,13.2 7.4,8.6 6,10 12,16 18,10 "></polygon></g>
1276 <g id="explore"><path d="M12,10.9c-0.6,0-1.1,0.5-1.1,1.1s0.5,1.1,1.1,1.1c0.6,0,1.1-0.5,1.1-1.1S12.6,10.9,12,10.9z M12,2C6.5,2,2,6.5,2,12c0,5.5,4.5,10,10,10c5.5,0,10-4.5,10-10C22,6.5,17.5,2,12,2z M14.2,14.2L6,18l3.8-8.2L18,6L14.2,14.2z"></path></g>
1277 <g id="extension"><path d="M20.5,11H19V7c0-1.1-0.9-2-2-2h-4V3.5C13,2.1,11.9,1,10.5,1C9.1,1,8,2.1,8,3.5V5H4C2.9,5,2,5.9,2,7l0,3.8h1.5c1.5,0,2.7,1.2,2.7,2.7S5,16.2,3.5,16.2H2L2,20c0,1.1,0.9,2,2,2h3.8v-1.5c0-1.5,1.2-2.7,2.7-2.7c1.5,0,2.7,1.2,2.7,2.7V22H17c1.1,0,2-0.9,2-2v-4h1.5c1.4,0,2.5-1.1,2.5-2.5S21.9,11,20.5,11z"></path></g>
1278 <g id="favorite"><path d="M12,21.4L10.6,20C5.4,15.4,2,12.3,2,8.5C2,5.4,4.4,3,7.5,3c1.7,0,3.4,0.8,4.5,2.1C13.1,3.8,14.8,3,16.5,3C19.6,3,22,5.4,22,8.5c0,3.8-3.4,6.9-8.6,11.5L12,21.4z"></path></g>
1279 <g id="favorite-outline"><path d="M16.5,3c-1.7,0-3.4,0.8-4.5,2.1C10.9,3.8,9.2,3,7.5,3C4.4,3,2,5.4,2,8.5c0,3.8,3.4,6.9,8.6,11.5l1.4,1.3l1.4-1.3c5.1-4.7,8.6-7.8,8.6-11.5C22,5.4,19.6,3,16.5,3z M12.1,18.6L12,18.6l-0.1-0.1C7.1,14.2,4,11.4,4,8.5C4,6.5,5.5,5,7.5,5c1.5,0,3,1,3.6,2.4h1.9C13.5,6,15,5,16.5,5c2,0,3.5,1.5,3.5,3.5C20,11.4,16.9,14.2,12.1,18.6z"></path></g>
1280 <g id="file-download"><path d="M19,9h-4V3H9v6H5l7,7L19,9z M5,18v2h14v-2H5z"></path></g>
1281 <g id="file-upload"><polygon points="9,16 15,16 15,10 19,10 12,3 5,10 9,10 "><rect x="5" y="18" width="14" height="2"></rect></polygon></g>
1282 <g id="filter"><path d="M10,18h4v-2h-4V18z M3,6v2h18V6H3z M6,13h12v-2H6V13z"></path></g>
1283 <g id="flag"><polygon points="14.4,6 14,4 5,4 5,21 7,21 7,14 12.6,14 13,16 20,16 20,6 "></polygon></g>
1284 <g id="flip-to-back"><path d="M9,7H7l0,2h2V7z M9,11H7v2h2V11z M9,3C7.9,3,7,3.9,7,5h2V3z M13,15h-2v2h2V15z M19,3v2h2C21,3.9,20.1,3,19,3z M13,3h-2v2h2V3z M9,17v-2H7C7,16.1,7.9,17,9,17z M19,13h2v-2h-2V13z M19,9h2V7h-2V9z M19,17c1.1,0,2-0.9,2-2h-2V17z M5,7H3v2h0l0,10c0,1.1,0.9,2,2,2h12v-2H5V7z M15,5h2V3h-2V5z M15,17h2v-2h-2V17z"></path></g>
1285 <g id="flip-to-front"><path d="M3,13h2v-2H3L3,13z M3,17h2v-2H3V17z M5,21v-2H3C3,20.1,3.9,21,5,21z M3,9h2V7H3V9z M15,21h2v-2h-2V21z M19,3H9C7.9,3,7,3.9,7,5v2h0v2v6c0,1.1,0.9,2,2,2h5h4h1c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,15H9V5h10V15z M11,21h2v-2h-2V21z M7,21h2v-2H7V21z"></path></g>
1286 <g id="folder"><path d="M10,4H4C2.9,4,2,4.9,2,6l0,12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V8c0-1.1-0.9-2-2-2h-8L10,4z"></path></g>
1287 <g id="folder-mydrive"><path d="M20,6h-8l-2-2H4C2.9,4,2,4.9,2,6l0,12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V8C22,6.9,21.1,6,20,6z M11.7,17l-1.3-2.1l2.8-5l1.5,2.7L12.3,17H11.7z M18.3,17h-5.5l1.4-2.5h5.1l0.3,0.5L18.3,17z M13.8,9h2.4l2.8,5H16l-2.6-4.5L13.8,9z"></path></g>
1288 <g id="folder-shared"><path d="M20,6h-8l-2-2H4C2.9,4,2,4.9,2,6l0,12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V8C22,6.9,21.1,6,20,6z M15,9c1.1,0,2,0.9,2,2c0,1.1-0.9,2-2,2c-1.1,0-2-0.9-2-2C13,9.9,13.9,9,15,9z M19,17h-8v-1c0-1.3,2.7-2,4-2c1.3,0,4,0.7,4,2V17z"></path></g>
1289 <g id="forward"><polygon points="12,8 12,4 20,12 12,20 12,16 4,16 4,8 "></polygon></g>
1290 <g id="fullscreen"><path d="M7,14H5v5h5v-2H7V14z M5,10h2V7h3V5H5V10z M17,17h-3v2h5v-5h-2V17z M14,5v2h3v3h2V5H14z"></path></g>
1291 <g id="fullscreen-exit"><path d="M5,16h3v3h2v-5H5V16z M8,8H5v2h5V5H8V8z M14,19h2v-3h3v-2h-5V19z M16,8V5h-2v5h5V8H16z"></path></g>
1292 <g id="gesture"><path d="M4.6,6.9C5.3,6.2,6,5.5,6.3,5.7c0.5,0.2,0,1-0.3,1.5c-0.3,0.4-2.9,3.9-2.9,6.3c0,1.3,0.5,2.3,1.3,3c0.8,0.6,1.7,0.7,2.6,0.5c1.1-0.3,1.9-1.4,3.1-2.8c1.2-1.5,2.8-3.4,4.1-3.4c1.6,0,1.6,1,1.8,1.8c-3.8,0.6-5.4,3.7-5.4,5.4c0,1.7,1.4,3.1,3.2,3.1c1.6,0,4.3-1.3,4.7-6.1H21v-2.5h-2.5c-0.2-1.6-1.1-4.2-4-4.2c-2.2,0-4.2,1.9-4.9,2.8c-0.6,0.7-2.1,2.5-2.3,2.7c-0.3,0.3-0.7,0.8-1.1,0.8c-0.4,0-0.7-0.8-0.4-1.9c0.4-1.1,1.4-2.9,1.9-3.5C8.4,8,8.9,7.2,8.9,5.9C8.9,3.7,7.3,3,6.4,3C5.1,3,4,4,3.7,4.3C3.4,4.6,3.1,4.9,2.8,5.2L4.6,6.9z M13.9,18.6c-0.3,0-0.7-0.3-0.7-0.7c0-0.6,0.7-2.2,2.9-2.8C15.7,17.8,14.6,18.6,13.9,18.6z"></path></g>
1293 <g id="google"><path d="M16.3,13.4l-1.1-0.8c-0.4-0.3-0.8-0.7-0.8-1.4c0-0.7,0.5-1.3,1-1.6c1.3-1,2.6-2.1,2.6-4.3c0-2.1-1.3-3.3-2-3.9h1.7L18.9,0h-6.2C8.3,0,6.1,2.8,6.1,5.8c0,2.3,1.8,4.8,5,4.8h0.8c-0.1,0.3-0.4,0.8-0.4,1.3c0,1,0.4,1.4,0.9,2c-1.4,0.1-4,0.4-5.9,1.6c-1.8,1.1-2.3,2.6-2.3,3.7c0,2.3,2.1,4.5,6.6,4.5c5.4,0,8-3,8-5.9C18.8,15.7,17.7,14.6,16.3,13.4z M8.7,4.3c0-2.2,1.3-3.2,2.7-3.2c2.6,0,4,3.5,4,5.5c0,2.6-2.1,3.1-2.9,3.1C10,9.7,8.7,6.6,8.7,4.3z M12.3,22.3c-3.3,0-5.4-1.5-5.4-3.7c0-2.2,2-2.9,2.6-3.2c1.3-0.4,3-0.5,3.3-0.5c0.3,0,0.5,0,0.7,0c2.4,1.7,3.4,2.4,3.4,4C16.9,20.8,15,22.3,12.3,22.3z"></path></g>
1294 <g id="google-plus"><path d="M21,10V7h-2v3h-3v2h3v3h2v-3h3v-2H21z M13.3,13.4l-1.1-0.8c-0.4-0.3-0.8-0.7-0.8-1.4c0-0.7,0.5-1.3,1-1.6c1.3-1,2.6-2.1,2.6-4.3c0-2.1-1.3-3.3-2-3.9h1.7L15.9,0H9.7C5.3,0,3.1,2.8,3.1,5.8c0,2.3,1.8,4.8,5,4.8h0.8c-0.1,0.3-0.4,0.8-0.4,1.3c0,1,0.4,1.4,0.9,2c-1.4,0.1-4,0.4-5.9,1.6c-1.8,1.1-2.3,2.6-2.3,3.7c0,2.3,2.1,4.5,6.6,4.5c5.4,0,8-3,8-5.9C15.8,15.7,14.7,14.6,13.3,13.4z M5.7,4.3c0-2.2,1.3-3.2,2.7-3.2c2.6,0,4,3.5,4,5.5c0,2.6-2.1,3.1-2.9,3.1C7,9.7,5.7,6.6,5.7,4.3z M9.3,22.3c-3.3,0-5.4-1.5-5.4-3.7c0-2.2,2-2.9,2.6-3.2c1.3-0.4,3-0.5,3.3-0.5c0.3,0,0.5,0,0.7,0c2.4,1.7,3.4,2.4,3.4,4C13.9,20.8,12,22.3,9.3,22.3z"></path></g>
1295 <g id="help"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M13,19h-2v-2h2V19z M15.1,11.3l-0.9,0.9C13.4,12.9,13,13.5,13,15h-2v-0.5c0-1.1,0.4-2.1,1.2-2.8l1.2-1.3C13.8,10.1,14,9.6,14,9c0-1.1-0.9-2-2-2c-1.1,0-2,0.9-2,2H8c0-2.2,1.8-4,4-4c2.2,0,4,1.8,4,4C16,9.9,15.6,10.7,15.1,11.3z"></path></g>
1296 <g id="history"><path opacity="0.9" d="M12.5,2C9,2,5.9,3.9,4.3,6.8L2,4.5V11h6.5L5.7,8.2C7,5.7,9.5,4,12.5,4c4.1,0,7.5,3.4,7.5,7.5c0,4.1-3.4,7.5-7.5,7.5c-3.3,0-6-2.1-7.1-5H3.3c1.1,4,4.8,7,9.2,7c5.3,0,9.5-4.3,9.5-9.5S17.7,2,12.5,2z M11,7v5.1l4.7,2.8l0.8-1.3l-4-2.4V7H11z"></path></g>
1297 <g id="home"><polygon points="10,20 10,14 14,14 14,20 19,20 19,12 22,12 12,3 2,12 5,12 5,20 "></polygon></g>
1298 <g id="https"><path d="M18,8h-1V6c0-2.8-2.2-5-5-5C9.2,1,7,3.2,7,6v2H6c-1.1,0-2,0.9-2,2v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V10C20,8.9,19.1,8,18,8z M12,17c-1.1,0-2-0.9-2-2s0.9-2,2-2c1.1,0,2,0.9,2,2S13.1,17,12,17z M15.1,8H8.9V6c0-1.7,1.4-3.1,3.1-3.1c1.7,0,3.1,1.4,3.1,3.1V8z"></path></g>
1299 <g id="inbox"><path d="M19,3H5C3.9,3,3,3.9,3,5l0,14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,15h-4c0,1.7-1.3,3-3,3c-1.7,0-3-1.3-3-3H5V5h14V15z M16,10h-2V7h-4v3H8l4,4L16,10z"></path></g>
1300 <g id="info"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M13,17h-2v-6h2V17z M13,9h-2V7h2V9z"></path></g>
1301 <g id="info-outline"><path d="M11,17h2v-6h-2V17z M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z M11,9h2V7h-2V9z"></path></g>
1302 <g id="invert-colors"><path d="M17,12c0-2.8-2.2-5-5-5v10C14.8,17,17,14.8,17,12z M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,19h-7v-2c-2.8,0-5-2.2-5-5s2.2-5,5-5V5h7V19z"></path></g>
1303 <g id="keep"><path d="M16,12V4h1V2H7v2h1v8l-2,2v2h5.2v6h1.6v-6H18v-2L16,12z"></path></g>
1304 <g id="label"><path d="M17.6,5.8C17.3,5.3,16.7,5,16,5L5,5C3.9,5,3,5.9,3,7v10c0,1.1,0.9,2,2,2l11,0c0.7,0,1.3-0.3,1.6-0.8L22,12L17.6,5.8z"></path></g>
1305 <g id="label-outline"><path d="M17.6,5.8C17.3,5.3,16.7,5,16,5L5,5C3.9,5,3,5.9,3,7v10c0,1.1,0.9,2,2,2l11,0c0.7,0,1.3-0.3,1.6-0.8L22,12L17.6,5.8z M16,17H5V7h11l3.5,5L16,17z"></path></g>
1306 <g id="language"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M18.9,8H16c-0.3-1.3-0.8-2.4-1.4-3.6C16.4,5.1,18,6.3,18.9,8z M12,4c0.8,1.2,1.5,2.5,1.9,4h-3.8C10.5,6.6,11.2,5.2,12,4z M4.3,14C4.1,13.4,4,12.7,4,12s0.1-1.4,0.3-2h3.4c-0.1,0.7-0.1,1.3-0.1,2s0.1,1.3,0.1,2H4.3z M5.1,16H8c0.3,1.3,0.8,2.4,1.4,3.6C7.6,18.9,6,17.7,5.1,16z M8,8H5.1c1-1.7,2.5-2.9,4.3-3.6C8.8,5.6,8.3,6.7,8,8z M12,20c-0.8-1.2-1.5-2.5-1.9-4h3.8C13.5,17.4,12.8,18.8,12,20z M14.3,14H9.7c-0.1-0.7-0.2-1.3-0.2-2s0.1-1.3,0.2-2h4.7c0.1,0.7,0.2,1.3,0.2,2S14.4,13.3,14.3,14z M14.6,19.6c0.6-1.1,1.1-2.3,1.4-3.6h2.9C18,17.7,16.4,18.9,14.6,19.6z M16.4,14c0.1-0.7,0.1-1.3,0.1-2s-0.1-1.3-0.1-2h3.4c0.2,0.6,0.3,1.3,0.3,2s-0.1,1.4-0.3,2H16.4z"></path></g>
1307 <g id="launch"><path d="M19,19H5V5h7V3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2v-7h-2V19z M14,3v2h3.6l-9.8,9.8l1.4,1.4L19,6.4V10h2V3H14z"></path></g>
1308 <g id="link"><path d="M8,13h8v-2H8V13z M3.9,12c0-2.3,1.8-4.1,4.1-4.1h3V6H8c-3.3,0-6,2.7-6,6s2.7,6,6,6h3v-1.9H8C5.7,16.1,3.9,14.3,3.9,12z M16,6h-3v1.9h3c2.3,0,4.1,1.8,4.1,4.1c0,2.3-1.8,4.1-4.1,4.1h-3V18h3c3.3,0,6-2.7,6-6S19.3,6,16,6z"></path></g>
1309 <g id="list"><path d="M3,13h2v-2H3V13z M3,17h2v-2H3V17z M3,9h2V7H3V9z M7,13h14v-2H7V13z M7,17h14v-2H7V17z M7,7v2h14V7H7z"></path></g>
1310 <g id="lock"><path d="M18,8h-1V6c0-2.8-2.2-5-5-5C9.2,1,7,3.2,7,6v2H6c-1.1,0-2,0.9-2,2v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V10C20,8.9,19.1,8,18,8z M12,17c-1.1,0-2-0.9-2-2s0.9-2,2-2c1.1,0,2,0.9,2,2S13.1,17,12,17z M15.1,8H8.9V6c0-1.7,1.4-3.1,3.1-3.1c1.7,0,3.1,1.4,3.1,3.1V8z"></path></g>
1311 <g id="lock-open"><path d="M12,17c1.1,0,2-0.9,2-2s-0.9-2-2-2c-1.1,0-2,0.9-2,2S10.9,17,12,17z M18,8h-1V6c0-2.8-2.2-5-5-5C9.2,1,7,3.2,7,6h1.9c0-1.7,1.4-3.1,3.1-3.1c1.7,0,3.1,1.4,3.1,3.1v2H6c-1.1,0-2,0.9-2,2v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V10C20,8.9,19.1,8,18,8z M18,20H6V10h12V20z"></path></g>
1312 <g id="lock-outline"><path d="M18,8h-1V6c0-2.8-2.2-5-5-5C9.2,1,7,3.2,7,6v2H6c-1.1,0-2,0.9-2,2v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V10C20,8.9,19.1,8,18,8z M12,2.9c1.7,0,3.1,1.4,3.1,3.1v2H9V6H8.9C8.9,4.3,10.3,2.9,12,2.9z M18,20H6V10h12V20z M12,17c1.1,0,2-0.9,2-2s-0.9-2-2-2c-1.1,0-2,0.9-2,2S10.9,17,12,17z"></path></g>
1313 <g id="mail"><path d="M20,4H4C2.9,4,2,4.9,2,6l0,12c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V6C22,4.9,21.1,4,20,4z M20,8l-8,5L4,8V6l8,5l8-5V8z"></path></g>
1314 <g id="markunread"><path d="M22,6l2-2l-2-2l-2,2l-2-2l-2,2l-2-2l-2,2l-2-2L8,4L6,2L4,4L2,2L0,4l2,2L0,8l2,2l-2,2l2,2l-2,2l2,2l-2,2l2,2l2-2l2,2l2-2l2,2l2-2l2,2l2-2l2,2l2-2l2,2l2-2l-2-2l2-2l-2-2l2-2l-2-2l2-2L22,6z M20,8l-8,5L4,8V6l8,5l8-5V8z"></path></g>
1315 <g id="menu"><path d="M3,18h18v-2H3V18z M3,13h18v-2H3V13z M3,6v2h18V6H3z"></path></g>
1316 <g id="more-horiz"><path d="M6,10c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S7.1,10,6,10z M18,10c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S19.1,10,18,10z M12,10c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,10,12,10z"></path></g>
1317 <g id="more-vert"><path d="M12,8c1.1,0,2-0.9,2-2s-0.9-2-2-2c-1.1,0-2,0.9-2,2S10.9,8,12,8z M12,10c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,10,12,10z M12,16c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,16,12,16z"></path></g>
1318 <g id="polymer"><polygon points="19,4 15,4 7.1,16.6 4.5,12 9,4 5,4 0.5,12 5,20 9,20 16.9,7.4 19.5,12 15,20 19,20 23.5,12 "></polygon></g>
1319 <g id="print"><path d="M19,8H5c-1.7,0-3,1.3-3,3v6h4v4h12v-4h4v-6C22,9.3,20.7,8,19,8z M16,19H8v-5h8V19z M19,12c-0.6,0-1-0.4-1-1s0.4-1,1-1c0.6,0,1,0.4,1,1S19.6,12,19,12z M18,3H6v4h12V3z"></path></g>
1320 <g id="radio-button-off"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z"></path></g>
1321 <g id="radio-button-on"><path d="M12,7c-2.8,0-5,2.2-5,5s2.2,5,5,5c2.8,0,5-2.2,5-5S14.8,7,12,7z M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z"></path></g>
1322 <g id="receipt"><path d="M18,17H6v-2h12V17z M18,13H6v-2h12V13z M18,9H6V7h12V9z M3,22l1.5-1.5L6,22l1.5-1.5L9,22l1.5-1.5L12,22l1.5-1.5L15,22l1.5-1.5L18,22l1.5-1.5L21,22V2l-1.5,1.5L18,2l-1.5,1.5L15,2l-1.5,1.5L12,2l-1.5,1.5L9,2L7.5,3.5L6,2L4.5,3.5L3,2V22z"></path></g>
1323 <g id="refresh"><path d="M17.6,6.4C16.2,4.9,14.2,4,12,4c-4.4,0-8,3.6-8,8s3.6,8,8,8c3.7,0,6.8-2.6,7.7-6h-2.1c-0.8,2.3-3,4-5.6,4c-3.3,0-6-2.7-6-6s2.7-6,6-6c1.7,0,3.1,0.7,4.2,1.8L13,11h7V4L17.6,6.4z"></path></g>
1324 <g id="reminder"><path d="M16.9,13c1.3-1.3,2.1-3,2.1-5c0-3.9-3.1-7-7-7C8.1,1,5,4.1,5,8c0,2,0.8,3.7,2.1,5l0,0l3.5,3.5L6,21.1l1.4,1.4L16.9,13z M15.5,11.5L15.5,11.5L12,15.1l-3.5-3.5l0,0l0,0C7.6,10.6,7,9.4,7,8c0-2.8,2.2-5,5-5c2.8,0,5,2.2,5,5C17,9.4,16.4,10.6,15.5,11.5L15.5,11.5z M13.4,19.3l3.2,3.2l1.4-1.4l-3.2-3.2L13.4,19.3z"></path></g>
1325 <g id="remove"><path d="M19,13H5v-2h14V13z"></path></g>
1326 <g id="remove-circle"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M17,13H7v-2h10V13z"></path></g>
1327 <g id="remove-circle-outline"><path d="M7,11v2h10v-2H7z M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z"></path></g>
1328 <g id="reply"><path d="M10,9V5l-7,7l7,7v-4.1c5,0,8.5,1.6,11,5.1C20,15,17,10,10,9z"></path></g>
1329 <g id="reply-all"><path d="M7,8V5l-7,7l7,7v-3l-4-4L7,8z M13,9V5l-7,7l7,7v-4.1c5,0,8.5,1.6,11,5.1C23,15,20,10,13,9z"></path></g>
1330 <g id="report"><path d="M15.7,3H8.3L3,8.3v7.5L8.3,21h7.5l5.3-5.3V8.3L15.7,3z M12,17.3c-0.7,0-1.3-0.6-1.3-1.3c0-0.7,0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3C13.3,16.7,12.7,17.3,12,17.3z M13,13h-2V7h2V13z"></path></g>
1331 <g id="rotate-left"><path d="M7.1,8.5L5.7,7.1C4.8,8.3,4.2,9.6,4.1,11h2C6.2,10.1,6.6,9.3,7.1,8.5z M6.1,13h-2c0.2,1.4,0.7,2.7,1.6,3.9l1.4-1.4C6.6,14.7,6.2,13.9,6.1,13z M7.1,18.3c1.2,0.9,2.5,1.4,3.9,1.6v-2c-0.9-0.1-1.7-0.5-2.5-1L7.1,18.3z M13,4.1V1L8.5,5.5L13,10V6.1c2.8,0.5,5,2.9,5,5.9s-2.2,5.4-5,5.9v2c3.9-0.5,7-3.9,7-7.9S16.9,4.6,13,4.1z"></path></g>
1332 <g id="rotate-right"><path d="M15.5,5.5L11,1v3.1C7.1,4.6,4,7.9,4,12s3.1,7.4,7,7.9v-2C8.2,17.4,6,15,6,12s2.2-5.4,5-5.9V10L15.5,5.5z M19.9,11c-0.2-1.4-0.7-2.7-1.6-3.9l-1.4,1.4c0.5,0.8,0.9,1.6,1,2.5H19.9z M13,17.9v2c1.4-0.2,2.7-0.7,3.9-1.6l-1.4-1.4C14.7,17.4,13.9,17.8,13,17.9z M16.9,15.5l1.4,1.4c0.9-1.2,1.5-2.5,1.6-3.9h-2C17.8,13.9,17.4,14.7,16.9,15.5z"></path></g>
1333 <g id="save"><path d="M17,3H5C3.9,3,3,3.9,3,5l0,14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V7L17,3z M12,19c-1.7,0-3-1.3-3-3s1.3-3,3-3c1.7,0,3,1.3,3,3S13.7,19,12,19z M15,9H5V5h10V9z"></path></g>
1334 <g id="schedule"><path fill-opacity="0.9" d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M12,20c-4.4,0-8-3.6-8-8s3.6-8,8-8c4.4,0,8,3.6,8,8S16.4,20,12,20z"></path><polygon fill-opacity="0.9" points="12.5,7 11,7 11,13 16.2,16.2 17,14.9 12.5,12.2 "></polygon></g>
1335 <g id="search"><path d="M15.5,14h-0.8l-0.3-0.3c1-1.1,1.6-2.6,1.6-4.2C16,5.9,13.1,3,9.5,3C5.9,3,3,5.9,3,9.5S5.9,16,9.5,16c1.6,0,3.1-0.6,4.2-1.6l0.3,0.3v0.8l5,5l1.5-1.5L15.5,14z M9.5,14C7,14,5,12,5,9.5S7,5,9.5,5C12,5,14,7,14,9.5S12,14,9.5,14z"></path></g>
1336 <g id="select-all"><path d="M3,5h2V3C3.9,3,3,3.9,3,5z M3,13h2v-2H3V13z M7,21h2v-2H7V21z M3,9h2V7H3V9z M13,3h-2v2h2V3z M19,3v2h2C21,3.9,20.1,3,19,3z M5,21v-2H3C3,20.1,3.9,21,5,21z M3,17h2v-2H3V17z M9,3H7v2h2V3z M11,21h2v-2h-2V21z M19,13h2v-2h-2V13z M19,21c1.1,0,2-0.9,2-2h-2V21z M19,9h2V7h-2V9z M19,17h2v-2h-2V17z M15,21h2v-2h-2V21z M15,5h2V3h-2V5z M7,17h10V7H7V17z M9,9h6v6H9V9z"></path></g>
1337 <g id="send"><polygon points="2,21 23,12 2,3 2,10 17,12 2,14 "></polygon></g>
1338 <g id="settings"><path d="M19.4,13c0-0.3,0.1-0.6,0.1-1s0-0.7-0.1-1l2.1-1.7c0.2-0.2,0.2-0.4,0.1-0.6l-2-3.5C19.5,5.1,19.3,5,19,5.1l-2.5,1c-0.5-0.4-1.1-0.7-1.7-1l-0.4-2.6C14.5,2.2,14.2,2,14,2h-4C9.8,2,9.5,2.2,9.5,2.4L9.1,5.1C8.5,5.3,8,5.7,7.4,6.1L5,5.1C4.7,5,4.5,5.1,4.3,5.3l-2,3.5C2.2,8.9,2.3,9.2,2.5,9.4L4.6,11c0,0.3-0.1,0.6-0.1,1s0,0.7,0.1,1l-2.1,1.7c-0.2,0.2-0.2,0.4-0.1,0.6l2,3.5C4.5,18.9,4.7,19,5,18.9l2.5-1c0.5,0.4,1.1,0.7,1.7,1l0.4,2.6c0,0.2,0.2,0.4,0.5,0.4h4c0.2,0,0.5-0.2,0.5-0.4l0.4-2.6c0.6-0.3,1.2-0.6,1.7-1l2.5,1c0.2,0.1,0.5,0,0.6-0.2l2-3.5c0.1-0.2,0.1-0.5-0.1-0.6L19.4,13z M12,15.5c-1.9,0-3.5-1.6-3.5-3.5s1.6-3.5,3.5-3.5s3.5,1.6,3.5,3.5S13.9,15.5,12,15.5z"></path></g>
1339 <g id="settings-applications"><path d="M12,10c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S13.1,10,12,10z M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17.2,12c0,0.2,0,0.5,0,0.7l1.5,1.2c0.1,0.1,0.2,0.3,0.1,0.4l-1.4,2.4c-0.1,0.2-0.3,0.2-0.4,0.2l-1.7-0.7c-0.4,0.3-0.8,0.5-1.2,0.7l-0.3,1.9c0,0.2-0.2,0.3-0.3,0.3h-2.8c-0.2,0-0.3-0.1-0.3-0.3L10,16.9c-0.4-0.2-0.8-0.4-1.2-0.7l-1.7,0.7c-0.2,0.1-0.3,0-0.4-0.2l-1.4-2.4c-0.1-0.2,0-0.3,0.1-0.4l1.5-1.2c0-0.2,0-0.5,0-0.7s0-0.5,0-0.7l-1.5-1.2c-0.1-0.1-0.2-0.3-0.1-0.4l1.4-2.4c0.1-0.2,0.3-0.2,0.4-0.2l1.7,0.7C9.2,7.6,9.6,7.3,10,7.1l0.3-1.9c0-0.2,0.2-0.3,0.3-0.3h2.8c0.2,0,0.3,0.1,0.3,0.3L14,7.1c0.4,0.2,0.8,0.4,1.2,0.7l1.7-0.7c0.2-0.1,0.3,0,0.4,0.2l1.4,2.4c0.1,0.2,0,0.3-0.1,0.4l-1.5,1.2C17.2,11.5,17.2,11.8,17.2,12z"></path></g>
1340 <g id="settings-bluetooth"><path d="M11,24h2v-2h-2V24z M7,24h2v-2H7V24z M15,24h2v-2h-2V24z M17.7,5.7L12,0h-1v7.6L6.4,3L5,4.4l5.6,5.6L5,15.6L6.4,17l4.6-4.6V20h1l5.7-5.7L13.4,10L17.7,5.7z M13,3.8l1.9,1.9L13,7.6V3.8z M14.9,14.3L13,16.2v-3.8L14.9,14.3z"></path></g>
1341 <g id="settings-cell"><path d="M7,24h2v-2H7V24z M11,24h2v-2h-2V24z M15,24h2v-2h-2V24z M16,0L8,0C6.9,0,6,0.9,6,2v16c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2V2C18,0.9,17.1,0,16,0z M16,16H8V4h8V16z"></path></g>
1342 <g id="settings-phone"><path d="M13,9h-2v2h2V9z M17,9h-2v2h2V9z M20,15.5c-1.2,0-2.4-0.2-3.6-0.6c-0.3-0.1-0.7,0-1,0.2l-2.2,2.2c-2.8-1.4-5.1-3.8-6.6-6.6l2.2-2.2c0.3-0.3,0.4-0.7,0.2-1C8.7,6.4,8.5,5.2,8.5,4c0-0.6-0.4-1-1-1H4C3.4,3,3,3.4,3,4c0,9.4,7.6,17,17,17c0.6,0,1-0.4,1-1v-3.5C21,15.9,20.6,15.5,20,15.5z M19,9v2h2V9H19z"></path></g>
1343 <g id="settings-power"><path d="M7,24h2v-2H7V24z M11,24h2v-2h-2V24z M13,2h-2v10h2V2z M16.6,4.4l-1.4,1.4C16.8,6.9,18,8.8,18,11c0,3.3-2.7,6-6,6c-3.3,0-6-2.7-6-6c0-2.2,1.2-4.1,2.9-5.1L7.4,4.4C5.4,5.9,4,8.3,4,11c0,4.4,3.6,8,8,8c4.4,0,8-3.6,8-8C20,8.3,18.6,5.9,16.6,4.4z M15,24h2v-2h-2V24z"></path></g>
1344 <g id="settings-voice"><path d="M7,24h2v-2H7V24z M12,13c1.7,0,3-1.3,3-3l0-6c0-1.7-1.3-3-3-3c-1.7,0-3,1.3-3,3v6C9,11.7,10.3,13,12,13z M11,24h2v-2h-2V24z M15,24h2v-2h-2V24z M19,10h-1.7c0,3-2.5,5.1-5.3,5.1c-2.8,0-5.3-2.1-5.3-5.1H5c0,3.4,2.7,6.2,6,6.7V20h2v-3.3C16.3,16.2,19,13.4,19,10z"></path></g>
1345 <g id="shopping-basket"><path d="M17.2,9l-4.4-6.6C12.6,2.2,12.3,2,12,2c-0.3,0-0.6,0.1-0.8,0.4L6.8,9H2c-0.6,0-1,0.4-1,1c0,0.1,0,0.2,0,0.3l2.5,9.3c0.2,0.8,1,1.5,1.9,1.5h13c0.9,0,1.7-0.6,1.9-1.5l2.5-9.3c0-0.1,0-0.2,0-0.3c0-0.6-0.4-1-1-1H17.2z M9,9l3-4.4L15,9H9z M12,17c-1.1,0-2-0.9-2-2s0.9-2,2-2c1.1,0,2,0.9,2,2S13.1,17,12,17z"></path></g>
1346 <g id="shopping-cart"><path d="M7,18c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S8.1,18,7,18z M1,2v2h2l3.6,7.6L5.2,14C5.1,14.3,5,14.7,5,15c0,1.1,0.9,2,2,2h12v-2H7.4c-0.1,0-0.2-0.1-0.2-0.2c0,0,0-0.1,0-0.1L8.1,13h7.4c0.8,0,1.4-0.4,1.7-1l3.6-6.5C21,5.3,21,5.2,21,5c0-0.6-0.4-1-1-1H5.2L4.3,2H1z M17,18c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S18.1,18,17,18z"></path></g>
1347 <g id="sort"><path d="M3,18h6v-2H3V18z M3,6v2h18V6H3z M3,13h12v-2H3V13z"></path></g>
1348 <g id="star"><polygon points="12,17.273 18.18,21 16.545,13.971 22,9.244 14.809,8.627 12,2 9.191,8.627 2,9.244 7.455,13.971 5.82,21 "></polygon></g>
1349 <g id="star-half"><path d="M22,9.744l-7.191-0.617L12,2.5L9.191,9.127L2,9.744v0l0,0l5.455,4.727L5.82,21.5L12,17.772l0,0l6.18,3.727l-1.635-7.029L22,9.744z M12,15.896V6.595l1.71,4.036l4.38,0.376l-3.322,2.878l0.996,4.281L12,15.896z"></path></g>
1350 <g id="star-outline"><path d="M22,9.244l-7.191-0.617L12,2L9.191,8.627L2,9.244l5.455,4.727L5.82,21L12,17.272L18.18,21l-1.635-7.029L22,9.244z M12,15.396l-3.763,2.27l0.996-4.281L5.91,10.507l4.38-0.376L12,6.095l1.71,4.036l4.38,0.376l-3.322,2.878l0.996,4.281L12,15.396z"></path></g>
1351 <g id="star-rate"><polygon points="12,14.3 15.7,17 14.3,12.6 18,10 13.5,10 12,5.5 10.5,10 6,10 9.7,12.6 8.3,17 "></polygon></g>
1352 <g id="store"><path d="M20,4H4v2h16V4z M21,14v-2l-1-5H4l-1,5v2h1v6h10v-6h4v6h2v-6H21z M12,18H6v-4h6V18z"></path></g>
1353 <g id="swap-driving-apps"><circle cx="6.5" cy="15.5" r="1.5"></circle><circle cx="17.5" cy="15.5" r="1.5"></circle><path d="M18.9,7c-0.2-0.6-0.8-1-1.4-1H16H6V4L3,7l2,2l1,1V8h11.7l1.3,4H3v9c0,0.6,0.4,1,1,1h1c0.6,0,1-0.4,1-1v-1h12v1c0,0.6,0.4,1,1,1h1c0.6,0,1-0.4,1-1v-8L18.9,7z M6.5,17C5.7,17,5,16.3,5,15.5S5.7,14,6.5,14C7.3,14,8,14.7,8,15.5S7.3,17,6.5,17z M17.5,17c-0.8,0-1.5-0.7-1.5-1.5s0.7-1.5,1.5-1.5c0.8,0,1.5,0.7,1.5,1.5S18.3,17,17.5,17z M16,0v2H8v2h8v2l3-3L16,0z"></path></g>
1354 <g id="swap-horiz"><path d="M7,11l-4,4l4,4v-3h7v-2H7V11z M21,9l-4-4v3h-7v2h7v3L21,9z"></path></g>
1355 <g id="swap-vert"><path d="M16,17v-7h-2v7h-3l4,4l4-4H16z M9,3L5,7h3v7h2V7h3L9,3z"></path></g>
1356 <g id="swap-vert-circle"><path d="M12,2C6.5,2,2,6.5,2,12s4.5,10,10,10c5.5,0,10-4.5,10-10S17.5,2,12,2z M6.5,9L10,5.5L13.5,9H11v4H9V9H6.5z M17.5,15L14,18.5L10.5,15H13v-4h2v4H17.5z"></path></g>
1357 <g id="tab"><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,19L5,19V5h7v4h7V19z"></path></g>
1358 <g id="tab-unselected"><path d="M3,9h2V7H3V9z M3,13h2v-2H3V13z M3,5h2V3C3.9,3,3,3.9,3,5z M7,21h2v-2l-2,0V21z M3,17h2v-2H3V17z M5,21v-2H3C3,20.1,3.9,21,5,21z M19,3h-8v6h10V5C21,3.9,20.1,3,19,3z M19,17h2v-2h-2V17z M7,5h2V3H7V5z M19,21c1.1,0,2-0.9,2-2h-2V21z M19,13h2v-2h-2V13z M11,21h2v-2l-2,0V21z M15,21h2v-2l-2,0V21z"></path></g>
1359 <g id="text-format"><path d="M5,17v2h14v-2H5z M9.5,12.8h5l0.9,2.2h2.1L12.8,4h-1.5L6.5,15h2.1L9.5,12.8z M12,6l1.9,5h-3.7L12,6z"></path></g>
1360 <g id="theaters"><path d="M18,3v2h-2V3H8v2H6V3H4v18h2v-2h2v2h8v-2h2v2h2V3H18z M8,17H6v-2h2V17z M8,13H6v-2h2V13z M8,9H6V7h2V9z M18,17h-2v-2h2V17z M18,13h-2v-2h2V13z M18,9h-2V7h2V9z"></path></g>
1361 <g id="thumb-down"><path d="M15,3H6C5.2,3,4.5,3.5,4.2,4.2l-3,7.1C1.1,11.5,1,11.7,1,12v1.9l0,0c0,0,0,0.1,0,0.1c0,1.1,0.9,2,2,2h6.3l-1,4.6c0,0.1,0,0.2,0,0.3c0,0.4,0.2,0.8,0.4,1.1L9.8,23l6.6-6.6c0.4-0.4,0.6-0.9,0.6-1.4V5C17,3.9,16.1,3,15,3z M19,3v12h4V3H19z"></path></g>
1362 <g id="thumb-up"><path d="M1,21h4V9H1V21z M23,10c0-1.1-0.9-2-2-2h-6.3l1-4.6c0-0.1,0-0.2,0-0.3c0-0.4-0.2-0.8-0.4-1.1L14.2,1L7.6,7.6C7.2,7.9,7,8.4,7,9v10c0,1.1,0.9,2,2,2h9c0.8,0,1.5-0.5,1.8-1.2l3-7.1c0.1-0.2,0.1-0.5,0.1-0.7V10L23,10C23,10.1,23,10,23,10z"></path></g>
1363 <g id="today"><path d="M19,3h-1V1h-2v2H8V1H6v2H5C3.9,3,3,3.9,3,5l0,14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,19H5V8h14V19z"></path><rect x="7" y="10" width="5" height="5"></rect></g>
1364 <g id="translate"><path d="M3,17.2V21h3.8L17.8,9.9l-3.8-3.8L3,17.2z M20.7,7c0.4-0.4,0.4-1,0-1.4l-2.3-2.3c-0.4-0.4-1-0.4-1.4,0l-1.8,1.8l3.8,3.8L20.7,7z M12,19l-2,2h13v-2H12z"></path></g>
1365 <g id="undo"><path d="M12,5V1.5l-5,5l5,5V7c3.3,0,6,2.7,6,6s-2.7,6-6,6c-3.3,0-6-2.7-6-6H4c0,4.4,3.6,8,8,8c4.4,0,8-3.6,8-8S16.4,5,12,5z"></path></g>
1366 <g id="unfold-less"><path d="M7.4,18.6L8.8,20l3.2-3.2l3.2,3.2l1.4-1.4L12,14L7.4,18.6z M16.6,5.4L15.2,4L12,7.2L8.8,4L7.4,5.4L12,10L16.6,5.4z"></path></g>
1367 <g id="unfold-more"><path d="M12,5.8L15.2,9l1.4-1.4L12,3L7.4,7.6L8.8,9L12,5.8z M12,18.2L8.8,15l-1.4,1.4L12,21l4.6-4.6L15.2,15L12,18.2z"></path></g>
1368 <g id="view-array"><path d="M4,18h3V5H4V18z M18,5v13h3V5H18z M8,18h9V5H8V18z"></path></g>
1369 <g id="view-column"><path d="M10,18h5V5h-5V18z M4,18h5V5H4V18z M16,5v13h5V5H16z"></path></g>
1370 <g id="view-headline"><path d="M4,15h17v-2H4V15z M4,19h17v-2H4V19z M4,11h17V9H4V11z M4,5v2h17V5H4z"></path></g>
1371 <g id="view-list"><path d="M4,14h4v-4H4V14z M4,19h4v-4H4V19z M4,9h4V5H4V9z M9,14h12v-4H9V14z M9,19h12v-4H9V19z M9,5v4h12V5H9z"></path></g>
1372 <g id="view-module"><path d="M4,11h5V5H4V11z M4,18h5v-6H4V18z M10,18h5v-6h-5V18z M16,18h5v-6h-5V18z M10,11h5V5h-5V11z M16,5v6h5V5H16z"></path></g>
1373 <g id="view-quilt"><path d="M10,18h5v-6h-5V18z M4,18h5V5H4V18z M16,18h5v-6h-5V18z M10,5v6h11V5H10z"></path></g>
1374 <g id="view-stream"><path d="M4,18h17v-6H4V18z M4,5v6h17V5H4z"></path></g>
1375 <g id="visibility"><path d="M12,4.5C7,4.5,2.7,7.6,1,12c1.7,4.4,6,7.5,11,7.5c5,0,9.3-3.1,11-7.5C21.3,7.6,17,4.5,12,4.5z M12,17c-2.8,0-5-2.2-5-5s2.2-5,5-5c2.8,0,5,2.2,5,5S14.8,17,12,17z M12,9c-1.7,0-3,1.3-3,3s1.3,3,3,3c1.7,0,3-1.3,3-3S13.7,9,12,9z"></path></g>
1376 <g id="visibility-off"><path d="M12,7c2.8,0,5,2.2,5,5c0,0.6-0.1,1.3-0.4,1.8l2.9,2.9c1.5-1.3,2.7-2.9,3.4-4.7c-1.7-4.4-6-7.5-11-7.5c-1.4,0-2.7,0.3-4,0.7l2.2,2.2C10.7,7.1,11.4,7,12,7z M2,4.3l2.3,2.3L4.7,7c-1.7,1.3-3,3-3.7,5c1.7,4.4,6,7.5,11,7.5c1.5,0,3-0.3,4.4-0.8l0.4,0.4l2.9,2.9l1.3-1.3L3.3,3L2,4.3z M7.5,9.8l1.5,1.5C9,11.6,9,11.8,9,12c0,1.7,1.3,3,3,3c0.2,0,0.4,0,0.7-0.1l1.5,1.5C13.5,16.8,12.8,17,12,17c-2.8,0-5-2.2-5-5C7,11.2,7.2,10.5,7.5,9.8z M11.8,9l3.1,3.1c0-0.1,0-0.1,0-0.2c0-1.7-1.3-3-3-3C11.9,9,11.9,9,11.8,9z"></path></g>
1377 <g id="warning"><path d="M1,21h22L12,2L1,21z M13,18h-2v-2h2V18z M13,14h-2v-4h2V14z"></path></g>
1378 <g id="work"><path d="M20,6h-4V4l-2-2h-4L8,4v2H4C2.9,6,2,6.9,2,8l0,11c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V8C22,6.9,21.1,6,20,6z M14,6h-4V4h4V6z"></path></g>
1382 <!-- import core-icon for convenience
1383 TODO(sorvell): we'd rather do this in core-iconset but we can't until
1384 crbug.com/373461 is addressed
1387 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1388 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1389 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1390 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1391 Code distributed by Google as part of the polymer project is also
1392 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1396 The `core-icon` element displays an icon using CSS background image. By default an icon renders as 24px square.
1400 <core-icon src="star.png"></core-icon>
1402 Example setting size to 32px x 32px:
1404 <core-icon src="big_star.png" size="32"></core-icon>
1406 Example using icon from default iconset:
1408 <core-icon icon="menu"></core-icon>
1410 Example using icon `cherry` from custom iconset `fruit`:
1412 <core-icon icon="fruit:cherry"></core-icon>
1414 See [core-iconset](#core-iconset) and [core-iconset-svg](#core-iconset-svg) for more information about
1415 how to use a custom iconset.
1417 See [core-icons](#core-icons) for the default set of icons. To use the default set of icons you'll need to include an import for `core-icons.html`.
1419 @group Polymer Core Elements
1421 @homepage polymer.github.io
1425 <style shim-shadowdom="">/* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1426 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1427 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1428 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1429 Code distributed by Google as part of the polymer project is also
1430 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */
1432 html /deep/ core-icon {
1433 display: inline-block;
1434 vertical-align: middle;
1435 background-repeat: no-repeat;
1438 html /deep/ core-icon[size=""] {
1442 html /deep/ core-icon[size=""] > svg {
1451 <polymer-element name="core-icon" attributes="src size icon" assetpath="../core-icon/">
1458 Polymer('core-icon', {
1461 * The URL of an image for the icon. If the src property is specified,
1462 * the icon property should not be.
1471 * Specifies the size of the icon in pixel units.
1480 * Specifies the icon name or index in the set of icons available in
1481 * the icon's icon set. If the icon property is specified,
1482 * the src property should not be.
1491 'size icon': 'updateIcon'
1494 defaultIconset: 'icons',
1498 meta = document.createElement('core-iconset');
1503 srcChanged: function() {
1504 this.style.backgroundImage = 'url(' + this.src + ')';
1505 this.style.backgroundPosition = 'center';
1506 this.style.backgroundSize = this.size + 'px ' + this.size + 'px';
1509 getIconset: function(name) {
1510 return meta.byId(name || this.defaultIconset);
1513 updateIcon: function() {
1515 this.style.width = this.style.height = this.size + 'px';
1518 var parts = String(this.icon).split(':');
1519 var icon = parts.pop();
1521 var set = this.getIconset(parts.pop());
1523 set.applyIcon(this, icon, this.size / set.iconSize);
1538 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1539 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1540 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1541 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1542 Code distributed by Google as part of the polymer project is also
1543 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1547 `core-icon-button` is an icon with button behaviors.
1549 <core-icon-button src="star.png"></core-icon-button>
1551 `core-icon-button` includes a default icon set. Use `icon` to specify
1552 which icon from the icon set to use.
1554 <core-icon-button icon="menu"></core-icon-button>
1556 See [`core-iconset`](#core-iconset) for more information about
1557 how to use a custom icon set.
1559 @group Polymer Core Elements
1560 @element core-icon-button
1567 <polymer-element name="core-icon-button" attributes="src icon active" assetpath="../core-icon-button/">
1572 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1573 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
1574 The complete set of authors may be found at http://polymer.github.io/AUTHORS
1575 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
1576 Code distributed by Google as part of the polymer project is also
1577 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
1581 display: inline-block;
1582 box-sizing: border-box;
1583 -moz-box-sizing: border-box;
1586 background-image: none;
1590 vertical-align: middle;
1597 pointer-events: none;
1601 box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
1604 :host(:hover:not([disabled])) {
1605 box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.1);
1608 :host(.selected:not([disabled])) {
1609 background-color: rgba(0, 0, 0, 0.05);
1610 box-shadow: inset 0 1px 0 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.12);
1613 :host(:active:not([disabled]), .selected:active:not([disabled])) {
1614 background-color: rgba(0, 0, 0, 0.05);
1615 box-shadow: inset 0 1px 0 0 rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.12);
1618 :host(.core-dark-theme.outline) {
1619 background-color: rgba(200, 200, 200, 0.05);
1620 box-shadow: 0 0 0 1px rgba(200, 200, 200, 0.1);
1623 :host(.core-dark-theme:hover) {
1624 background-color: rgba(200, 200, 200, 0.05);
1625 box-shadow: 0 1px 0 0 rgba(200, 200, 200, 0.12), 0 0 0 1px rgba(200, 200, 200, 0.1);
1628 :host(.core-dark-theme.selected) {
1629 background-color: rgba(220, 220, 220, 0.05);
1630 box-shadow: inset 0 1px 0 0 rgba(200, 200, 200, 0.05), 0 0 0 1px rgba(200, 200, 200, 0.12);
1633 :host(.core-dark-theme:active, .core-dark-theme.selected:active) {
1634 background-color: rgba(200, 200, 200, 0.05);
1635 box-shadow: inset 0 1px 0 0 rgba(200, 200, 200, 0.1), 0 0 0 1px rgba(200, 200, 200, 0.12);
1639 pointer-events: none;
1643 <core-icon src="{{src}}" icon="{{icon}}"><content></content></core-icon>
1649 Polymer('core-icon-button', {
1652 * The URL of an image for the icon. Should not use `icon` property
1653 * if you are using this property.
1662 * If true, border is placed around the button to indicate it's
1672 * Specifies the icon name or index in the set of icons available in
1673 * the icon set. Should not use `src` property if you are using this
1682 activeChanged: function() {
1683 this.classList.toggle('selected', this.active);
1693 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1694 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1695 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1696 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1697 Code distributed by Google as part of the polymer project is also
1698 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1702 `core-toolbar` is a horizontal bar containing elements that can be used for
1703 label, navigation, search and actions.
1706 <core-icon-button icon="menu" on-tap="{{menuAction}}"></core-icon-button>
1707 <div flex>Title</div>
1708 <core-icon-button icon="more" on-tap="{{moreAction}}"></core-icon-button>
1711 `core-toolbar` has a standard height, but can made be taller by setting `tall`
1712 class on the `core-toolbar`. This will make the toolbar 3x the normal height.
1714 <core-toolbar class="tall">
1715 <core-icon-button icon="menu"></core-icon-button>
1718 Apply `medium-tall` class to make the toolbar medium tall. This will make the
1719 toolbar 2x the normal height.
1721 <core-toolbar class="medium-tall">
1722 <core-icon-button icon="menu"></core-icon-button>
1725 When taller, elements can pin to either the top (default), middle or bottom.
1727 <core-toolbar class="tall">
1728 <core-icon-button icon="menu"></core-icon-button>
1729 <div class="middle indent">Middle Title</div>
1730 <div class="bottom indent">Bottom Title</div>
1733 To make an element completely fit at the bottom of the toolbar, use `fit` along
1736 <core-toolbar class="tall">
1737 <div id="progressBar" class="bottom fit"></div>
1740 @group Polymer Core Elements
1741 @element core-toolbar
1747 <polymer-element name="core-toolbar" noscript="" assetpath="../core-toolbar/">
1751 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1752 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1753 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1754 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1755 Code distributed by Google as part of the polymer project is also
1756 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1763 box-sizing: border-box;
1764 -moz-box-sizing: border-box;
1770 background-color: #CFD8DC;
1775 transition: height 0.18s ease-in;
1778 :host(.medium-tall) {
1789 pointer-events: none;
1797 :host(.narrow.medium-tall) {
1801 :host(.narrow.tall) {
1805 :host(.narrow) .toolbar-tools {
1818 :host(.tall, .medium-tall) #middleBar {
1819 -webkit-transform: translateY(100%);
1820 transform: translateY(100%);
1831 /* shows bottom bar only when in normal height (!tall && !medium-tall) */
1832 :host(.animate.no-overlap) > #topBar,
1833 :host(.animate.no-overlap) > #middleBar {
1834 transition: -webkit-transform 0.18s ease-in;
1835 transition: transform 0.18s ease-in;
1838 :host(.no-overlap:not(.medium-tall):not(.tall)) > #topBar {
1839 -webkit-transform: translateY(-100%);
1840 transform: translateY(-100%);
1843 :host(.no-overlap:not(.medium-tall):not(.tall)) > #middleBar {
1844 -webkit-transform: translateY(-200%);
1845 transform: translateY(-200%);
1848 /* make elements (e.g. buttons) respond to mouse/touch events */
1849 polyfill-next-selector { content: '.toolbar-tools > *'; }
1851 pointer-events: auto;
1854 /* elements spacing */
1855 polyfill-next-selector { content: '.toolbar-tools > *'; }
1861 polyfill-next-selector { content: '.toolbar-tools > .fit'; }
1872 polyfill-next-selector { content: ':host .indent'; }
1873 ::content > .indent {
1878 <div id="bottomBar" class="toolbar-tools" center="" horizontal="" layout="">
1879 <content select=".bottom"></content>
1882 <div id="middleBar" class="toolbar-tools" center="" horizontal="" layout="">
1883 <content select=".middle"></content>
1886 <div id="topBar" class="toolbar-tools" center="" horizontal="" layout="">
1894 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1895 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1896 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1897 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1898 Code distributed by Google as part of the polymer project is also
1899 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1903 `core-header-panel` contains a header section and a content panel section.
1905 __Important:__ The `core-header-panel` will not display if its parent does not have a height.
1907 Using [layout attributes](http://www.polymer-project.org/docs/polymer/layout-attrs.html), you can easily make the `core-header-panel` fill the screen
1909 <body fullbleed layout vertical>
1910 <core-header-panel flex>
1912 <div>Hello World!</div>
1914 </core-header-panel>
1917 or, if you would prefer to do it in CSS, just give `html`, `body`, and `core-header-panel` a height of 100%:
1928 support is provided for scrolling modes when one uses a core-toolbar or equivalent
1929 for the header section.
1934 <core-toolbar>Header</core-toolbar>
1935 <div>Content goes here...</div>
1936 </core-header-panel>
1938 If you want to use other than `core-toolbar` for the header, add
1939 `core-header` class to that element.
1944 <div class="core-header">Header</div>
1945 <div>Content goes here...</div>
1946 </core-header-panel>
1948 Use `mode` to control the header and scrolling behavior.
1950 @group Polymer Core Elements
1951 @element core-header-panel
1957 <polymer-element name="core-header-panel" assetpath="../core-header-panel/">
1961 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
1962 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1963 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1964 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1965 Code distributed by Google as part of the polymer project is also
1966 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1982 -webkit-overflow-scrolling: touch;
1993 -webkit-overflow-scrolling: touch;
2002 box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4);
2005 #dropShadow.hidden {
2012 :host([mode=scroll]) #mainContainer {
2019 :host([mode=cover]) #mainPanel {
2023 :host([mode=cover]) #mainContainer {
2031 :host([mode=cover]) #dropShadow {
2037 <div id="outerContainer" on-scroll="{{scroll}}" vertical="" layout="">
2039 <content id="headerContent" select="core-toolbar, .core-header"></content>
2041 <div id="mainPanel" flex="" vertical="" layout="">
2043 <div id="mainContainer" flex?="{{mode !== 'cover'}}" on-scroll="{{scroll}}">
2044 <content id="mainContent" select="*"></content>
2047 <div id="dropShadow"></div>
2056 Polymer('core-header-panel', {
2060 * Controls header and scrolling behavior. Options are
2061 * `standard`, `seamed`, `waterfall`, `waterfall-tall`,
2062 * `waterfall-medium-tall`, `scroll` and `cover`.
2063 * Default is `standard`.
2065 * `standard`: The header is a step above the panel. The header will consume the
2066 * panel at the point of entry, preventing it from passing through to the
2069 * `seamed`: The header is presented as seamed with the panel.
2071 * `waterfall`: Similar to standard mode, but header is initially presented as
2072 * seamed with panel, but then separates to form the step.
2074 * `waterfall-tall`: The header is initially taller (`tall` class is added to
2075 * the header). As the user scrolls, the header separates (forming an edge)
2076 * while condensing (`tall` class is removed from the header).
2078 * `scroll`: The header keeps its seam with the panel, and is pushed off screen.
2080 * `cover`: The panel covers the whole `core-header-panel` including the
2081 * header. This allows user to style the panel in such a way that the panel is
2082 * partially covering the header.
2085 * core-header-panel[mode=cover]::shadow #mainContainer {
2089 * margin: 60px 60px 60px 0;
2093 * <core-header-panel mode="cover">
2094 * <core-appbar class="tall">
2095 * <core-icon-button icon="menu"></core-icon-button>
2097 * <div class="content"></div>
2098 * </core-header-panel>
2104 mode: {value: '', reflect: true},
2107 * The class used in waterfall-tall mode. Change this if the header
2108 * accepts a different class for toggling height, e.g. "medium-tall"
2110 * @attribute tallClass
2117 * If true, the drop-shadow is always shown no matter what mode is set to.
2126 domReady: function() {
2127 this.async('scroll');
2130 modeChanged: function() {
2135 return this.$.headerContent.getDistributedNodes()[0];
2138 scroll: function() {
2139 var shadowMode = {'waterfall': 1, 'waterfall-tall': 1};
2140 var noShadow = {'seamed': 1, 'cover': 1, 'scroll': 1};
2141 var tallMode = {'waterfall-tall': 1};
2143 var main = this.$.mainContainer;
2144 var header = this.header;
2146 var sTop = main.scrollTop;
2147 var atTop = sTop === 0;
2150 this.$.dropShadow.classList.toggle('hidden', !this.shadow &&
2151 (atTop && shadowMode[this.mode] || noShadow[this.mode]));
2153 if (tallMode[this.mode]) {
2154 header.classList.toggle(this.tallClass, atTop);
2157 header.classList.toggle('animate', tallMode[this.mode]);
2167 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
2168 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
2169 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
2170 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
2171 Code distributed by Google as part of the polymer project is also
2172 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
2177 * marked - a markdown parser
2178 * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
2179 * https://github.com/chjj/marked
2185 * Block-Level Grammar
2190 code: /^( {4}[^\n]+\n*)+/,
2192 hr: /^( *[-*_]){3,} *(?:\n+|$)/,
2193 heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
2195 lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
2196 blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
2197 list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
2198 html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
2199 def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
2201 paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
2205 block.bullet = /(?:[*+-]|\d+\.)/;
2206 block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
2207 block.item = replace(block.item, 'gm')
2208 (/bull/g, block.bullet)
2211 block.list = replace(block.list)
2212 (/bull/g, block.bullet)
2213 ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
2214 ('def', '\\n+(?=' + block.def.source + ')')
2217 block.blockquote = replace(block.blockquote)
2221 block._tag = '(?!(?:'
2222 + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
2223 + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
2224 + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
2226 block.html = replace(block.html)
2227 ('comment', /<!--[\s\S]*?-->/)
2228 ('closed', /<(tag)[\s\S]+?<\/\1>/)
2229 ('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
2230 (/tag/g, block._tag)
2233 block.paragraph = replace(block.paragraph)
2235 ('heading', block.heading)
2236 ('lheading', block.lheading)
2237 ('blockquote', block.blockquote)
2238 ('tag', '<' + block._tag)
2243 * Normal Block Grammar
2246 block.normal = merge({}, block);
2252 block.gfm = merge({}, block.normal, {
2253 fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
2257 block.gfm.paragraph = replace(block.paragraph)
2259 + block.gfm.fences.source.replace('\\1', '\\2') + '|'
2260 + block.list.source.replace('\\1', '\\3') + '|')
2264 * GFM + Tables Block Grammar
2267 block.tables = merge({}, block.gfm, {
2268 nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
2269 table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
2276 function Lexer(options) {
2278 this.tokens.links = {};
2279 this.options = options || marked.defaults;
2280 this.rules = block.normal;
2282 if (this.options.gfm) {
2283 if (this.options.tables) {
2284 this.rules = block.tables;
2286 this.rules = block.gfm;
2292 * Expose Block Rules
2295 Lexer.rules = block;
2301 Lexer.lex = function(src, options) {
2302 var lexer = new Lexer(options);
2303 return lexer.lex(src);
2310 Lexer.prototype.lex = function(src) {
2312 .replace(/\r\n|\r/g, '\n')
2313 .replace(/\t/g, ' ')
2314 .replace(/\u00a0/g, ' ')
2315 .replace(/\u2424/g, '\n');
2317 return this.token(src, true);
2324 Lexer.prototype.token = function(src, top, bq) {
2325 var src = src.replace(/^ +$/gm, '')
2338 if (cap = this.rules.newline.exec(src)) {
2339 src = src.substring(cap[0].length);
2340 if (cap[0].length > 1) {
2348 if (cap = this.rules.code.exec(src)) {
2349 src = src.substring(cap[0].length);
2350 cap = cap[0].replace(/^ {4}/gm, '');
2353 text: !this.options.pedantic
2354 ? cap.replace(/\n+$/, '')
2361 if (cap = this.rules.fences.exec(src)) {
2362 src = src.substring(cap[0].length);
2372 if (cap = this.rules.heading.exec(src)) {
2373 src = src.substring(cap[0].length);
2376 depth: cap[1].length,
2382 // table no leading pipe (gfm)
2383 if (top && (cap = this.rules.nptable.exec(src))) {
2384 src = src.substring(cap[0].length);
2388 header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
2389 align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
2390 cells: cap[3].replace(/\n$/, '').split('\n')
2393 for (i = 0; i < item.align.length; i++) {
2394 if (/^ *-+: *$/.test(item.align[i])) {
2395 item.align[i] = 'right';
2396 } else if (/^ *:-+: *$/.test(item.align[i])) {
2397 item.align[i] = 'center';
2398 } else if (/^ *:-+ *$/.test(item.align[i])) {
2399 item.align[i] = 'left';
2401 item.align[i] = null;
2405 for (i = 0; i < item.cells.length; i++) {
2406 item.cells[i] = item.cells[i].split(/ *\| */);
2409 this.tokens.push(item);
2415 if (cap = this.rules.lheading.exec(src)) {
2416 src = src.substring(cap[0].length);
2419 depth: cap[2] === '=' ? 1 : 2,
2426 if (cap = this.rules.hr.exec(src)) {
2427 src = src.substring(cap[0].length);
2435 if (cap = this.rules.blockquote.exec(src)) {
2436 src = src.substring(cap[0].length);
2439 type: 'blockquote_start'
2442 cap = cap[0].replace(/^ *> ?/gm, '');
2444 // Pass `top` to keep the current
2445 // "toplevel" state. This is exactly
2446 // how markdown.pl works.
2447 this.token(cap, top, true);
2450 type: 'blockquote_end'
2457 if (cap = this.rules.list.exec(src)) {
2458 src = src.substring(cap[0].length);
2463 ordered: bull.length > 1
2466 // Get each top-level item.
2467 cap = cap[0].match(this.rules.item);
2473 for (; i < l; i++) {
2476 // Remove the list item's bullet
2477 // so it is seen as the next token.
2478 space = item.length;
2479 item = item.replace(/^ *([*+-]|\d+\.) +/, '');
2481 // Outdent whatever the
2482 // list item contains. Hacky.
2483 if (~item.indexOf('\n ')) {
2484 space -= item.length;
2485 item = !this.options.pedantic
2486 ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
2487 : item.replace(/^ {1,4}/gm, '');
2490 // Determine whether the next list item belongs here.
2491 // Backpedal if it does not belong in this list.
2492 if (this.options.smartLists && i !== l - 1) {
2493 b = block.bullet.exec(cap[i + 1])[0];
2494 if (bull !== b && !(bull.length > 1 && b.length > 1)) {
2495 src = cap.slice(i + 1).join('\n') + src;
2500 // Determine whether item is loose or not.
2501 // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
2502 // for discount behavior.
2503 loose = next || /\n\n(?!\s*$)/.test(item);
2505 next = item.charAt(item.length - 1) === '\n';
2506 if (!loose) loose = next;
2511 ? 'loose_item_start'
2516 this.token(item, false, bq);
2519 type: 'list_item_end'
2531 if (cap = this.rules.html.exec(src)) {
2532 src = src.substring(cap[0].length);
2534 type: this.options.sanitize
2537 pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
2544 if ((!bq && top) && (cap = this.rules.def.exec(src))) {
2545 src = src.substring(cap[0].length);
2546 this.tokens.links[cap[1].toLowerCase()] = {
2554 if (top && (cap = this.rules.table.exec(src))) {
2555 src = src.substring(cap[0].length);
2559 header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
2560 align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
2561 cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
2564 for (i = 0; i < item.align.length; i++) {
2565 if (/^ *-+: *$/.test(item.align[i])) {
2566 item.align[i] = 'right';
2567 } else if (/^ *:-+: *$/.test(item.align[i])) {
2568 item.align[i] = 'center';
2569 } else if (/^ *:-+ *$/.test(item.align[i])) {
2570 item.align[i] = 'left';
2572 item.align[i] = null;
2576 for (i = 0; i < item.cells.length; i++) {
2577 item.cells[i] = item.cells[i]
2578 .replace(/^ *\| *| *\| *$/g, '')
2582 this.tokens.push(item);
2587 // top-level paragraph
2588 if (top && (cap = this.rules.paragraph.exec(src))) {
2589 src = src.substring(cap[0].length);
2592 text: cap[1].charAt(cap[1].length - 1) === '\n'
2593 ? cap[1].slice(0, -1)
2600 if (cap = this.rules.text.exec(src)) {
2601 // Top-level should never reach here.
2602 src = src.substring(cap[0].length);
2612 Error('Infinite loop on byte: ' + src.charCodeAt(0));
2620 * Inline-Level Grammar
2624 escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
2625 autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
2627 tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
2628 link: /^!?\[(inside)\]\(href\)/,
2629 reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
2630 nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
2631 strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
2632 em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
2633 code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
2634 br: /^ {2,}\n(?!\s*$)/,
2636 text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
2639 inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
2640 inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
2642 inline.link = replace(inline.link)
2643 ('inside', inline._inside)
2644 ('href', inline._href)
2647 inline.reflink = replace(inline.reflink)
2648 ('inside', inline._inside)
2652 * Normal Inline Grammar
2655 inline.normal = merge({}, inline);
2658 * Pedantic Inline Grammar
2661 inline.pedantic = merge({}, inline.normal, {
2662 strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
2663 em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
2667 * GFM Inline Grammar
2670 inline.gfm = merge({}, inline.normal, {
2671 escape: replace(inline.escape)('])', '~|])')(),
2672 url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
2673 del: /^~~(?=\S)([\s\S]*?\S)~~/,
2674 text: replace(inline.text)
2676 ('|', '|https?://|')
2681 * GFM + Line Breaks Inline Grammar
2684 inline.breaks = merge({}, inline.gfm, {
2685 br: replace(inline.br)('{2,}', '*')(),
2686 text: replace(inline.gfm.text)('{2,}', '*')()
2690 * Inline Lexer & Compiler
2693 function InlineLexer(links, options) {
2694 this.options = options || marked.defaults;
2696 this.rules = inline.normal;
2697 this.renderer = this.options.renderer || new Renderer;
2698 this.renderer.options = this.options;
2702 Error('Tokens array requires a `links` property.');
2705 if (this.options.gfm) {
2706 if (this.options.breaks) {
2707 this.rules = inline.breaks;
2709 this.rules = inline.gfm;
2711 } else if (this.options.pedantic) {
2712 this.rules = inline.pedantic;
2717 * Expose Inline Rules
2720 InlineLexer.rules = inline;
2723 * Static Lexing/Compiling Method
2726 InlineLexer.output = function(src, links, options) {
2727 var inline = new InlineLexer(links, options);
2728 return inline.output(src);
2735 InlineLexer.prototype.output = function(src) {
2744 if (cap = this.rules.escape.exec(src)) {
2745 src = src.substring(cap[0].length);
2751 if (cap = this.rules.autolink.exec(src)) {
2752 src = src.substring(cap[0].length);
2753 if (cap[2] === '@') {
2754 text = cap[1].charAt(6) === ':'
2755 ? this.mangle(cap[1].substring(7))
2756 : this.mangle(cap[1]);
2757 href = this.mangle('mailto:') + text;
2759 text = escape(cap[1]);
2762 out += this.renderer.link(href, null, text);
2767 if (!this.inLink && (cap = this.rules.url.exec(src))) {
2768 src = src.substring(cap[0].length);
2769 text = escape(cap[1]);
2771 out += this.renderer.link(href, null, text);
2776 if (cap = this.rules.tag.exec(src)) {
2777 if (!this.inLink && /^<a /i.test(cap[0])) {
2779 } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
2780 this.inLink = false;
2782 src = src.substring(cap[0].length);
2783 out += this.options.sanitize
2790 if (cap = this.rules.link.exec(src)) {
2791 src = src.substring(cap[0].length);
2793 out += this.outputLink(cap, {
2797 this.inLink = false;
2802 if ((cap = this.rules.reflink.exec(src))
2803 || (cap = this.rules.nolink.exec(src))) {
2804 src = src.substring(cap[0].length);
2805 link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
2806 link = this.links[link.toLowerCase()];
2807 if (!link || !link.href) {
2808 out += cap[0].charAt(0);
2809 src = cap[0].substring(1) + src;
2813 out += this.outputLink(cap, link);
2814 this.inLink = false;
2819 if (cap = this.rules.strong.exec(src)) {
2820 src = src.substring(cap[0].length);
2821 out += this.renderer.strong(this.output(cap[2] || cap[1]));
2826 if (cap = this.rules.em.exec(src)) {
2827 src = src.substring(cap[0].length);
2828 out += this.renderer.em(this.output(cap[2] || cap[1]));
2833 if (cap = this.rules.code.exec(src)) {
2834 src = src.substring(cap[0].length);
2835 out += this.renderer.codespan(escape(cap[2], true));
2840 if (cap = this.rules.br.exec(src)) {
2841 src = src.substring(cap[0].length);
2842 out += this.renderer.br();
2847 if (cap = this.rules.del.exec(src)) {
2848 src = src.substring(cap[0].length);
2849 out += this.renderer.del(this.output(cap[1]));
2854 if (cap = this.rules.text.exec(src)) {
2855 src = src.substring(cap[0].length);
2856 out += escape(this.smartypants(cap[0]));
2862 Error('Infinite loop on byte: ' + src.charCodeAt(0));
2873 InlineLexer.prototype.outputLink = function(cap, link) {
2874 var href = escape(link.href)
2875 , title = link.title ? escape(link.title) : null;
2877 return cap[0].charAt(0) !== '!'
2878 ? this.renderer.link(href, title, this.output(cap[1]))
2879 : this.renderer.image(href, title, escape(cap[1]));
2883 * Smartypants Transformations
2886 InlineLexer.prototype.smartypants = function(text) {
2887 if (!this.options.smartypants) return text;
2890 .replace(/--/g, '\u2014')
2892 .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
2893 // closing singles & apostrophes
2894 .replace(/'/g, '\u2019')
2896 .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
2898 .replace(/"/g, '\u201d')
2900 .replace(/\.{3}/g, '\u2026');
2907 InlineLexer.prototype.mangle = function(text) {
2913 for (; i < l; i++) {
2914 ch = text.charCodeAt(i);
2915 if (Math.random() > 0.5) {
2916 ch = 'x' + ch.toString(16);
2918 out += '&#' + ch + ';';
2928 function Renderer(options) {
2929 this.options = options || {};
2932 Renderer.prototype.code = function(code, lang, escaped) {
2933 if (this.options.highlight) {
2934 var out = this.options.highlight(code, lang);
2935 if (out != null && out !== code) {
2942 return '<pre><code>'
2943 + (escaped ? code : escape(code, true))
2944 + '\n</code></pre>';
2947 return '<pre><code class="'
2948 + this.options.langPrefix
2949 + escape(lang, true)
2951 + (escaped ? code : escape(code, true))
2952 + '\n</code></pre>\n';
2955 Renderer.prototype.blockquote = function(quote) {
2956 return '<blockquote>\n' + quote + '</blockquote>\n';
2959 Renderer.prototype.html = function(html) {
2963 Renderer.prototype.heading = function(text, level, raw) {
2967 + this.options.headerPrefix
2968 + raw.toLowerCase().replace(/[^\w]+/g, '-')
2976 Renderer.prototype.hr = function() {
2977 return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
2980 Renderer.prototype.list = function(body, ordered) {
2981 var type = ordered ? 'ol' : 'ul';
2982 return '<' + type + '>\n' + body + '</' + type + '>\n';
2985 Renderer.prototype.listitem = function(text) {
2986 return '<li>' + text + '</li>\n';
2989 Renderer.prototype.paragraph = function(text) {
2990 return '<p>' + text + '</p>\n';
2993 Renderer.prototype.table = function(header, body) {
3004 Renderer.prototype.tablerow = function(content) {
3005 return '<tr>\n' + content + '</tr>\n';
3008 Renderer.prototype.tablecell = function(content, flags) {
3009 var type = flags.header ? 'th' : 'td';
3010 var tag = flags.align
3011 ? '<' + type + ' style="text-align:' + flags.align + '">'
3013 return tag + content + '</' + type + '>\n';
3016 // span level renderer
3017 Renderer.prototype.strong = function(text) {
3018 return '<strong>' + text + '</strong>';
3021 Renderer.prototype.em = function(text) {
3022 return '<em>' + text + '</em>';
3025 Renderer.prototype.codespan = function(text) {
3026 return '<code>' + text + '</code>';
3029 Renderer.prototype.br = function() {
3030 return this.options.xhtml ? '<br/>' : '<br>';
3033 Renderer.prototype.del = function(text) {
3034 return '<del>' + text + '</del>';
3037 Renderer.prototype.link = function(href, title, text) {
3038 if (this.options.sanitize) {
3040 var prot = decodeURIComponent(unescape(href))
3041 .replace(/[^\w:]/g, '')
3046 if (prot.indexOf('javascript:') === 0) {
3050 var out = '<a href="' + href + '"';
3052 out += ' title="' + title + '"';
3054 out += '>' + text + '</a>';
3058 Renderer.prototype.image = function(href, title, text) {
3059 var out = '<img src="' + href + '" alt="' + text + '"';
3061 out += ' title="' + title + '"';
3063 out += this.options.xhtml ? '/>' : '>';
3068 * Parsing & Compiling
3071 function Parser(options) {
3074 this.options = options || marked.defaults;
3075 this.options.renderer = this.options.renderer || new Renderer;
3076 this.renderer = this.options.renderer;
3077 this.renderer.options = this.options;
3081 * Static Parse Method
3084 Parser.parse = function(src, options, renderer) {
3085 var parser = new Parser(options, renderer);
3086 return parser.parse(src);
3093 Parser.prototype.parse = function(src) {
3094 this.inline = new InlineLexer(src.links, this.options, this.renderer);
3095 this.tokens = src.reverse();
3098 while (this.next()) {
3109 Parser.prototype.next = function() {
3110 return this.token = this.tokens.pop();
3114 * Preview Next Token
3117 Parser.prototype.peek = function() {
3118 return this.tokens[this.tokens.length - 1] || 0;
3125 Parser.prototype.parseText = function() {
3126 var body = this.token.text;
3128 while (this.peek().type === 'text') {
3129 body += '\n' + this.next().text;
3132 return this.inline.output(body);
3136 * Parse Current Token
3139 Parser.prototype.tok = function() {
3140 switch (this.token.type) {
3145 return this.renderer.hr();
3148 return this.renderer.heading(
3149 this.inline.output(this.token.text),
3154 return this.renderer.code(this.token.text,
3156 this.token.escaped);
3169 for (i = 0; i < this.token.header.length; i++) {
3170 flags = { header: true, align: this.token.align[i] };
3171 cell += this.renderer.tablecell(
3172 this.inline.output(this.token.header[i]),
3173 { header: true, align: this.token.align[i] }
3176 header += this.renderer.tablerow(cell);
3178 for (i = 0; i < this.token.cells.length; i++) {
3179 row = this.token.cells[i];
3182 for (j = 0; j < row.length; j++) {
3183 cell += this.renderer.tablecell(
3184 this.inline.output(row[j]),
3185 { header: false, align: this.token.align[j] }
3189 body += this.renderer.tablerow(cell);
3191 return this.renderer.table(header, body);
3193 case 'blockquote_start': {
3196 while (this.next().type !== 'blockquote_end') {
3200 return this.renderer.blockquote(body);
3202 case 'list_start': {
3204 , ordered = this.token.ordered;
3206 while (this.next().type !== 'list_end') {
3210 return this.renderer.list(body, ordered);
3212 case 'list_item_start': {
3215 while (this.next().type !== 'list_item_end') {
3216 body += this.token.type === 'text'
3221 return this.renderer.listitem(body);
3223 case 'loose_item_start': {
3226 while (this.next().type !== 'list_item_end') {
3230 return this.renderer.listitem(body);
3233 var html = !this.token.pre && !this.options.pedantic
3234 ? this.inline.output(this.token.text)
3236 return this.renderer.html(html);
3239 return this.renderer.paragraph(this.inline.output(this.token.text));
3242 return this.renderer.paragraph(this.parseText());
3251 function escape(html, encode) {
3253 .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
3254 .replace(/</g, '<')
3255 .replace(/>/g, '>')
3256 .replace(/"/g, '"')
3257 .replace(/'/g, ''');
3260 function unescape(html) {
3261 return html.replace(/&([#\w]+);/g, function(_, n) {
3262 n = n.toLowerCase();
3263 if (n === 'colon') return ':';
3264 if (n.charAt(0) === '#') {
3265 return n.charAt(1) === 'x'
3266 ? String.fromCharCode(parseInt(n.substring(2), 16))
3267 : String.fromCharCode(+n.substring(1));
3273 function replace(regex, opt) {
3274 regex = regex.source;
3276 return function self(name, val) {
3277 if (!name) return new RegExp(regex, opt);
3278 val = val.source || val;
3279 val = val.replace(/(^|[^\[])\^/g, '$1');
3280 regex = regex.replace(name, val);
3288 function merge(obj) {
3293 for (; i < arguments.length; i++) {
3294 target = arguments[i];
3295 for (key in target) {
3296 if (Object.prototype.hasOwnProperty.call(target, key)) {
3297 obj[key] = target[key];
3310 function marked(src, opt, callback) {
3311 if (callback || typeof opt === 'function') {
3317 opt = merge({}, marked.defaults, opt || {});
3319 var highlight = opt.highlight
3325 tokens = Lexer.lex(src, opt)
3330 pending = tokens.length;
3332 var done = function() {
3336 out = Parser.parse(tokens, opt);
3341 opt.highlight = highlight;
3345 : callback(null, out);
3348 if (!highlight || highlight.length < 3) {
3352 delete opt.highlight;
3354 if (!pending) return done();
3356 for (; i < tokens.length; i++) {
3358 if (token.type !== 'code') {
3359 return --pending || done();
3361 return highlight(token.text, token.lang, function(err, code) {
3362 if (code == null || code === token.text) {
3363 return --pending || done();
3366 token.escaped = true;
3367 --pending || done();
3375 if (opt) opt = merge({}, marked.defaults, opt);
3376 return Parser.parse(Lexer.lex(src, opt), opt);
3378 e.message += '\nPlease report this to https://github.com/chjj/marked.';
3379 if ((opt || marked.defaults).silent) {
3380 return '<p>An error occured:</p><pre>'
3381 + escape(e.message + '', true)
3393 marked.setOptions = function(opt) {
3394 merge(marked.defaults, opt);
3407 langPrefix: 'lang-',
3410 renderer: new Renderer,
3418 marked.Parser = Parser;
3419 marked.parser = Parser.parse;
3421 marked.Renderer = Renderer;
3423 marked.Lexer = Lexer;
3424 marked.lexer = Lexer.lex;
3426 marked.InlineLexer = InlineLexer;
3427 marked.inlineLexer = InlineLexer.output;
3429 marked.parse = marked;
3431 if (typeof exports === 'object') {
3432 module.exports = marked;
3433 } else if (typeof define === 'function' && define.amd) {
3434 define(function() { return marked; });
3436 this.marked = marked;
3439 }).call(function() {
3440 return this || (typeof window !== 'undefined' ? window : global);
3446 Element wrapper for the `marked` (http://marked.org/) library.
3448 @class marked-element
3449 @blurb Element wrapper for the marked library.
3453 <polymer-element name="marked-element" attributes="text" assetpath="../marked-element/">
3456 Polymer('marked-element', {
3460 attached: function() {
3462 highlight: this.highlight.bind(this)
3465 this.text = this.innerHTML;
3469 textChanged: function () {
3470 this.innerHTML = marked(this.text);
3473 highlight: function(code, lang) {
3474 var event = this.fire('marked-js-highlight', {code: code, lang: lang});
3475 return event.detail.code || code;
3484 <script>// Copyright (C) 2006 Google Inc.
3486 // Licensed under the Apache License, Version 2.0 (the "License");
3487 // you may not use this file except in compliance with the License.
3488 // You may obtain a copy of the License at
3490 // http://www.apache.org/licenses/LICENSE-2.0
3492 // Unless required by applicable law or agreed to in writing, software
3493 // distributed under the License is distributed on an "AS IS" BASIS,
3494 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3495 // See the License for the specific language governing permissions and
3496 // limitations under the License.
3501 * some functions for browser-side pretty printing of code contained in html.
3504 * For a fairly comprehensive set of languages see the
3505 * <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs">README</a>
3506 * file that came with this source. At a minimum, the lexer should work on a
3507 * number of languages including C and friends, Java, Python, Bash, SQL, HTML,
3508 * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk
3509 * and a subset of Perl, but, because of commenting conventions, doesn't work on
3510 * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class.
3513 * <li> include this source file in an html page via
3514 * {@code <script type="text/javascript" src="/path/to/prettify.js"><\/script>}
3515 * <li> define style rules. See the example page for examples.
3516 * <li> mark the {@code <pre>} and {@code <code>} tags in your source with
3517 * {@code class=prettyprint.}
3518 * You can also use the (html deprecated) {@code <xmp>} tag, but the pretty
3519 * printer needs to do more substantial DOM manipulations to support that, so
3520 * some css styles may not be preserved.
3522 * That's it. I wanted to keep the API as simple as possible, so there's no
3523 * need to specify which language the code is in, but if you wish, you can add
3524 * another class to the {@code <pre>} or {@code <code>} element to specify the
3525 * language, as in {@code <pre class="prettyprint lang-java">}. Any class that
3526 * starts with "lang-" followed by a file extension, specifies the file type.
3527 * See the "lang-*.js" files in this directory for code that implements
3528 * per-language file handlers.
3531 * cbeust, 2006/08/22
3533 * Java annotations (start with "@") are now captured as literals ("lit")
3538 // JSLint declarations
3539 /*global console, document, navigator, setTimeout, window, define */
3542 * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
3544 * If set to {@code false}, {@code prettyPrint()} is synchronous.
3546 window['PR_SHOULD_USE_CONTINUATION'] = true;
3549 * Find all the {@code <pre>} and {@code <code>} tags in the DOM with
3550 * {@code class=prettyprint} and prettify them.
3552 * @param {Function?} opt_whenDone if specified, called when the last entry
3553 * has been finished.
3557 * Pretty print a chunk of code.
3559 * @param {string} sourceCodeHtml code as html
3560 * @return {string} code as html, but prettier
3567 // Keyword lists for various languages.
3568 // We use things that coerce to strings to make them compact when minified
3569 // and to defeat aggressive optimizers that fold large string constants.
3570 var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
3571 var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
3572 "double,enum,extern,float,goto,int,long,register,short,signed,sizeof," +
3573 "static,struct,switch,typedef,union,unsigned,void,volatile"];
3574 var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
3575 "new,operator,private,protected,public,this,throw,true,try,typeof"];
3576 var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
3577 "concept,concept_map,const_cast,constexpr,decltype," +
3578 "dynamic_cast,explicit,export,friend,inline,late_check," +
3579 "mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast," +
3580 "template,typeid,typename,using,virtual,where"];
3581 var JAVA_KEYWORDS = [COMMON_KEYWORDS,
3582 "abstract,boolean,byte,extends,final,finally,implements,import," +
3583 "instanceof,null,native,package,strictfp,super,synchronized,throws," +
3585 var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
3586 "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
3587 "fixed,foreach,from,group,implicit,in,interface,internal,into,is,let," +
3588 "lock,object,out,override,orderby,params,partial,readonly,ref,sbyte," +
3589 "sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort," +
3590 "var,virtual,where"];
3591 var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
3592 "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
3593 "throw,true,try,unless,until,when,while,yes";
3594 var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
3595 "debugger,eval,export,function,get,null,set,undefined,var,with," +
3597 var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
3598 "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
3599 "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
3600 var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
3601 "elif,except,exec,finally,from,global,import,in,is,lambda," +
3602 "nonlocal,not,or,pass,print,raise,try,with,yield," +
3604 var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
3605 "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
3606 "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
3608 var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
3609 "function,in,local,set,then,until"];
3610 var ALL_KEYWORDS = [
3611 CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS +
3612 PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
3613 var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;
3615 // token style names. correspond to css classes
3617 * token style for a string literal
3620 var PR_STRING = 'str';
3622 * token style for a keyword
3625 var PR_KEYWORD = 'kwd';
3627 * token style for a comment
3630 var PR_COMMENT = 'com';
3632 * token style for a type
3635 var PR_TYPE = 'typ';
3637 * token style for a literal value. e.g. 1, null, true.
3640 var PR_LITERAL = 'lit';
3642 * token style for a punctuation string.
3645 var PR_PUNCTUATION = 'pun';
3647 * token style for plain text.
3650 var PR_PLAIN = 'pln';
3653 * token style for an sgml tag.
3658 * token style for a markup declaration such as a DOCTYPE.
3661 var PR_DECLARATION = 'dec';
3663 * token style for embedded source.
3666 var PR_SOURCE = 'src';
3668 * token style for an sgml attribute name.
3671 var PR_ATTRIB_NAME = 'atn';
3673 * token style for an sgml attribute value.
3676 var PR_ATTRIB_VALUE = 'atv';
3679 * A class that indicates a section of markup that is not code, e.g. to allow
3680 * embedding of line numbers within code listings.
3683 var PR_NOCODE = 'nocode';
3688 * A set of tokens that can precede a regular expression literal in
3690 * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
3691 * has the full list, but I've removed ones that might be problematic when
3692 * seen in languages that don't support regular expression literals.
3694 * <p>Specifically, I've removed any keywords that can't precede a regexp
3695 * literal in a syntactically legal javascript program, and I've removed the
3696 * "in" keyword since it's not a keyword in many languages, and might be used
3697 * as a count of inches.
3699 * <p>The link above does not accurately describe EcmaScript rules since
3700 * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
3701 * very well in practice.
3706 var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
3708 // CAVEAT: this does not properly handle the case where a regular
3709 // expression immediately follows another since a regular expression may
3710 // have flags for case-sensitivity and the like. Having regexp tokens
3711 // adjacent is not valid in any language I'm aware of, so I'm punting.
3712 // TODO: maybe style special characters inside a regexp as punctuation.
3716 * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
3717 * matches the union of the sets of strings matched by the input RegExp.
3718 * Since it matches globally, if the input strings have a start-of-input
3719 * anchor (/^.../), it is ignored for the purposes of unioning.
3720 * @param {Array.<RegExp>} regexs non multiline, non-global regexs.
3721 * @return {RegExp} a global regex.
3723 function combinePrefixPatterns(regexs) {
3724 var capturedGroupIndex = 0;
3726 var needToFoldCase = false;
3727 var ignoreCase = false;
3728 for (var i = 0, n = regexs.length; i < n; ++i) {
3729 var regex = regexs[i];
3730 if (regex.ignoreCase) {
3732 } else if (/[a-z]/i.test(regex.source.replace(
3733 /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
3734 needToFoldCase = true;
3740 var escapeCharToCodeUnit = {
3749 function decodeEscape(charsetPart) {
3750 var cc0 = charsetPart.charCodeAt(0);
3751 if (cc0 !== 92 /* \\ */) {
3754 var c1 = charsetPart.charAt(1);
3755 cc0 = escapeCharToCodeUnit[c1];
3758 } else if ('0' <= c1 && c1 <= '7') {
3759 return parseInt(charsetPart.substring(1), 8);
3760 } else if (c1 === 'u' || c1 === 'x') {
3761 return parseInt(charsetPart.substring(2), 16);
3763 return charsetPart.charCodeAt(1);
3767 function encodeEscape(charCode) {
3768 if (charCode < 0x20) {
3769 return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
3771 var ch = String.fromCharCode(charCode);
3772 return (ch === '\\' || ch === '-' || ch === ']' || ch === '^')
3776 function caseFoldCharset(charSet) {
3777 var charsetParts = charSet.substring(1, charSet.length - 1).match(
3779 '\\\\u[0-9A-Fa-f]{4}'
3780 + '|\\\\x[0-9A-Fa-f]{2}'
3781 + '|\\\\[0-3][0-7]{0,2}'
3788 var inverse = charsetParts[0] === '^';
3791 if (inverse) { out.push('^'); }
3793 for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
3794 var p = charsetParts[i];
3795 if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
3798 var start = decodeEscape(p);
3800 if (i + 2 < n && '-' === charsetParts[i + 1]) {
3801 end = decodeEscape(charsetParts[i + 2]);
3806 ranges.push([start, end]);
3807 // If the range might intersect letters, then expand it.
3808 // This case handling is too simplistic.
3809 // It does not deal with non-latin case folding.
3810 // It works for latin source code identifiers though.
3811 if (!(end < 65 || start > 122)) {
3812 if (!(end < 65 || start > 90)) {
3813 ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
3815 if (!(end < 97 || start > 122)) {
3816 ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
3822 // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
3823 // -> [[1, 12], [14, 14], [16, 17]]
3824 ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
3825 var consolidatedRanges = [];
3827 for (var i = 0; i < ranges.length; ++i) {
3828 var range = ranges[i];
3829 if (range[0] <= lastRange[1] + 1) {
3830 lastRange[1] = Math.max(lastRange[1], range[1]);
3832 consolidatedRanges.push(lastRange = range);
3836 for (var i = 0; i < consolidatedRanges.length; ++i) {
3837 var range = consolidatedRanges[i];
3838 out.push(encodeEscape(range[0]));
3839 if (range[1] > range[0]) {
3840 if (range[1] + 1 > range[0]) { out.push('-'); }
3841 out.push(encodeEscape(range[1]));
3845 return out.join('');
3848 function allowAnywhereFoldCaseAndRenumberGroups(regex) {
3849 // Split into character sets, escape sequences, punctuation strings
3850 // like ('(', '(?:', ')', '^'), and runs of characters that do not
3851 // include any of the above.
3852 var parts = regex.source.match(
3855 + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
3856 + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
3857 + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
3858 + '|\\\\[0-9]+' // a back-reference or octal escape
3859 + '|\\\\[^ux0-9]' // other escape sequence
3860 + '|\\(\\?[:!=]' // start of a non-capturing group
3861 + '|[\\(\\)\\^]' // start/end of a group, or line start
3862 + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
3865 var n = parts.length;
3867 // Maps captured group numbers to the number they will occupy in
3868 // the output or to -1 if that has not been determined, or to
3869 // undefined if they need not be capturing in the output.
3870 var capturedGroups = [];
3872 // Walk over and identify back references to build the capturedGroups
3874 for (var i = 0, groupIndex = 0; i < n; ++i) {
3877 // groups are 1-indexed, so max group index is count of '('
3879 } else if ('\\' === p.charAt(0)) {
3880 var decimalValue = +p.substring(1);
3882 if (decimalValue <= groupIndex) {
3883 capturedGroups[decimalValue] = -1;
3885 // Replace with an unambiguous escape sequence so that
3886 // an octal escape sequence does not turn into a backreference
3887 // to a capturing group from an earlier regex.
3888 parts[i] = encodeEscape(decimalValue);
3894 // Renumber groups and reduce capturing groups to non-capturing groups
3896 for (var i = 1; i < capturedGroups.length; ++i) {
3897 if (-1 === capturedGroups[i]) {
3898 capturedGroups[i] = ++capturedGroupIndex;
3901 for (var i = 0, groupIndex = 0; i < n; ++i) {
3905 if (!capturedGroups[groupIndex]) {
3908 } else if ('\\' === p.charAt(0)) {
3909 var decimalValue = +p.substring(1);
3910 if (decimalValue && decimalValue <= groupIndex) {
3911 parts[i] = '\\' + capturedGroups[decimalValue];
3916 // Remove any prefix anchors so that the output will match anywhere.
3917 // ^^ really does mean an anchored match though.
3918 for (var i = 0; i < n; ++i) {
3919 if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
3922 // Expand letters to groups to handle mixing of case-sensitive and
3923 // case-insensitive patterns if necessary.
3924 if (regex.ignoreCase && needToFoldCase) {
3925 for (var i = 0; i < n; ++i) {
3927 var ch0 = p.charAt(0);
3928 if (p.length >= 2 && ch0 === '[') {
3929 parts[i] = caseFoldCharset(p);
3930 } else if (ch0 !== '\\') {
3931 // TODO: handle letters in numeric escapes.
3932 parts[i] = p.replace(
3935 var cc = ch.charCodeAt(0);
3936 return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
3942 return parts.join('');
3946 for (var i = 0, n = regexs.length; i < n; ++i) {
3947 var regex = regexs[i];
3948 if (regex.global || regex.multiline) { throw new Error('' + regex); }
3950 '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
3953 return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
3958 * Split markup into a string of source code and an array mapping ranges in
3959 * that string to the text nodes in which they appear.
3962 * The HTML DOM structure:</p>
3966 * (Text "print ")) ; #1
3967 * (Text "'Hello '") ; #2
3968 * (Element "br") ; #3
3969 * (Text " + 'World';")) ; #4
3972 * corresponds to the HTML
3973 * {@code <p><b>print </b>'Hello '<br> + 'World';</p>}.</p>
3976 * It will produce the output:</p>
3979 * sourceCode: "print 'Hello '\n + 'World';",
3981 * // 012345678901234 5678901234567
3982 * spans: [0, #1, 6, #2, 14, #3, 15, #4]
3986 * where #1 is a reference to the {@code "print "} text node above, and so
3987 * on for the other text nodes.
3991 * The {@code} spans array is an array of pairs. Even elements are the start
3992 * indices of substrings, and odd elements are the text nodes (or BR elements)
3993 * that contain the text for those substrings.
3994 * Substrings continue until the next index or the end of the source.
3997 * @param {Node} node an HTML DOM subtree containing source-code.
3998 * @param {boolean} isPreformatted true if white-space in text nodes should
3999 * be considered significant.
4000 * @return {Object} source code and the text nodes in which they occur.
4002 function extractSourceSpans(node, isPreformatted) {
4003 var nocode = /(?:^|\s)nocode(?:\s|$)/;
4010 function walk(node) {
4011 switch (node.nodeType) {
4013 if (nocode.test(node.className)) { return; }
4014 for (var child = node.firstChild; child; child = child.nextSibling) {
4017 var nodeName = node.nodeName.toLowerCase();
4018 if ('br' === nodeName || 'li' === nodeName) {
4020 spans[k << 1] = length++;
4021 spans[(k++ << 1) | 1] = node;
4024 case 3: case 4: // Text
4025 var text = node.nodeValue;
4027 if (!isPreformatted) {
4028 text = text.replace(/[ \t\r\n]+/g, ' ');
4030 text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
4032 // TODO: handle tabs here?
4034 spans[k << 1] = length;
4035 length += text.length;
4036 spans[(k++ << 1) | 1] = node;
4045 sourceCode: chunks.join('').replace(/\n$/, ''),
4052 * Apply the given language handler to sourceCode and add the resulting
4053 * decorations to out.
4054 * @param {number} basePos the index of sourceCode within the chunk of source
4055 * whose decorations are already present on out.
4057 function appendDecorations(basePos, sourceCode, langHandler, out) {
4058 if (!sourceCode) { return; }
4060 sourceCode: sourceCode,
4064 out.push.apply(out, job.decorations);
4070 * Given an element, if it contains only one child element and any text nodes
4071 * it contains contain only space characters, return the sole child element.
4072 * Otherwise returns undefined.
4074 * This is meant to return the CODE element in {@code <pre><code ...>} when
4075 * there is a single child element that contains all the non-space textual
4076 * content, but not to return anything where there are multiple child elements
4077 * as in {@code <pre><code>...</code><code>...</code></pre>} or when there
4078 * is textual content.
4080 function childContentWrapper(element) {
4081 var wrapper = undefined;
4082 for (var c = element.firstChild; c; c = c.nextSibling) {
4083 var type = c.nodeType;
4084 wrapper = (type === 1) // Element Node
4085 ? (wrapper ? element : c)
4086 : (type === 3) // Text Node
4087 ? (notWs.test(c.nodeValue) ? element : wrapper)
4090 return wrapper === element ? undefined : wrapper;
4093 /** Given triples of [style, pattern, context] returns a lexing function,
4094 * The lexing function interprets the patterns to find token boundaries and
4095 * returns a decoration list of the form
4096 * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
4097 * where index_n is an index into the sourceCode, and style_n is a style
4098 * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
4099 * all characters in sourceCode[index_n-1:index_n].
4101 * The stylePatterns is a list whose elements have the form
4102 * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
4104 * Style is a style constant like PR_PLAIN, or can be a string of the
4105 * form 'lang-FOO', where FOO is a language extension describing the
4106 * language of the portion of the token in $1 after pattern executes.
4107 * E.g., if style is 'lang-lisp', and group 1 contains the text
4108 * '(hello (world))', then that portion of the token will be passed to the
4109 * registered lisp handler for formatting.
4110 * The text before and after group 1 will be restyled using this decorator
4111 * so decorators should take care that this doesn't result in infinite
4112 * recursion. For example, the HTML lexer rule for SCRIPT elements looks
4113 * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
4114 * '<script>foo()<\/script>', which would cause the current decorator to
4115 * be called with '<script>' which would not match the same rule since
4116 * group 1 must not be empty, so it would be instead styled as PR_TAG by
4117 * the generic tag rule. The handler registered for the 'js' extension would
4118 * then be called with 'foo()', and finally, the current decorator would
4119 * be called with '<\/script>' which would not match the original rule and
4120 * so the generic tag rule would identify it as a tag.
4122 * Pattern must only match prefixes, and if it matches a prefix, then that
4123 * match is considered a token with the same style.
4125 * Context is applied to the last non-whitespace, non-comment token
4128 * Shortcut is an optional string of characters, any of which, if the first
4129 * character, gurantee that this pattern and only this pattern matches.
4131 * @param {Array} shortcutStylePatterns patterns that always start with
4132 * a known character. Must have a shortcut string.
4133 * @param {Array} fallthroughStylePatterns patterns that will be tried in
4134 * order if the shortcut ones fail. May have shortcuts.
4136 * @return {function (Object)} a
4137 * function that takes source code and returns a list of decorations.
4139 function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
4143 var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
4146 for (var i = 0, n = allPatterns.length; i < n; ++i) {
4147 var patternParts = allPatterns[i];
4148 var shortcutChars = patternParts[3];
4149 if (shortcutChars) {
4150 for (var c = shortcutChars.length; --c >= 0;) {
4151 shortcuts[shortcutChars.charAt(c)] = patternParts;
4154 var regex = patternParts[1];
4156 if (!regexKeys.hasOwnProperty(k)) {
4157 allRegexs.push(regex);
4158 regexKeys[k] = null;
4161 allRegexs.push(/[\0-\uffff]/);
4162 tokenizer = combinePrefixPatterns(allRegexs);
4165 var nPatterns = fallthroughStylePatterns.length;
4168 * Lexes job.sourceCode and produces an output array job.decorations of
4169 * style classes preceded by the position at which they start in
4170 * job.sourceCode in order.
4172 * @param {Object} job an object like <pre>{
4173 * sourceCode: {string} sourceText plain text,
4174 * basePos: {int} position of job.sourceCode in the larger chunk of
4178 var decorate = function (job) {
4179 var sourceCode = job.sourceCode, basePos = job.basePos;
4180 /** Even entries are positions in source in ascending order. Odd enties
4181 * are style markers (e.g., PR_COMMENT) that run from that position until
4183 * @type {Array.<number|string>}
4185 var decorations = [basePos, PR_PLAIN];
4186 var pos = 0; // index into sourceCode
4187 var tokens = sourceCode.match(tokenizer) || [];
4188 var styleCache = {};
4190 for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
4191 var token = tokens[ti];
4192 var style = styleCache[token];
4196 if (typeof style === 'string') {
4199 var patternParts = shortcuts[token.charAt(0)];
4201 match = token.match(patternParts[1]);
4202 style = patternParts[0];
4204 for (var i = 0; i < nPatterns; ++i) {
4205 patternParts = fallthroughStylePatterns[i];
4206 match = token.match(patternParts[1]);
4208 style = patternParts[0];
4213 if (!match) { // make sure that we make progress
4218 isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
4219 if (isEmbedded && !(match && typeof match[1] === 'string')) {
4224 if (!isEmbedded) { styleCache[token] = style; }
4227 var tokenStart = pos;
4228 pos += token.length;
4231 decorations.push(basePos + tokenStart, style);
4232 } else { // Treat group 1 as an embedded block of source code.
4233 var embeddedSource = match[1];
4234 var embeddedSourceStart = token.indexOf(embeddedSource);
4235 var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
4237 // If embeddedSource can be blank, then it would match at the
4238 // beginning which would cause us to infinitely recurse on the
4239 // entire token, so we catch the right context in match[2].
4240 embeddedSourceEnd = token.length - match[2].length;
4241 embeddedSourceStart = embeddedSourceEnd - embeddedSource.length;
4243 var lang = style.substring(5);
4244 // Decorate the left of the embedded source
4246 basePos + tokenStart,
4247 token.substring(0, embeddedSourceStart),
4248 decorate, decorations);
4249 // Decorate the embedded source
4251 basePos + tokenStart + embeddedSourceStart,
4253 langHandlerForExtension(lang, embeddedSource),
4255 // Decorate the right of the embedded section
4257 basePos + tokenStart + embeddedSourceEnd,
4258 token.substring(embeddedSourceEnd),
4259 decorate, decorations);
4262 job.decorations = decorations;
4267 /** returns a function that produces a list of decorations from source text.
4269 * This code treats ", ', and ` as string delimiters, and \ as a string
4270 * escape. It does not recognize perl's qq() style strings.
4271 * It has no special handling for double delimiter escapes as in basic, or
4272 * the tripled delimiters used in python, but should work on those regardless
4273 * although in those cases a single string literal may be broken up into
4274 * multiple adjacent string literals.
4276 * It recognizes C, C++, and shell style comments.
4278 * @param {Object} options a set of optional parameters.
4279 * @return {function (Object)} a function that examines the source code
4280 * in the input job and builds the decoration list.
4282 function sourceDecorator(options) {
4283 var shortcutStylePatterns = [], fallthroughStylePatterns = [];
4284 if (options['tripleQuotedStrings']) {
4285 // '''multi-line-string''', 'single-line-string', and double-quoted
4286 shortcutStylePatterns.push(
4287 [PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
4289 } else if (options['multiLineStrings']) {
4290 // 'multi-line-string', "multi-line-string"
4291 shortcutStylePatterns.push(
4292 [PR_STRING, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
4295 // 'single-line-string', "single-line-string"
4296 shortcutStylePatterns.push(
4298 /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
4301 if (options['verbatimStrings']) {
4302 // verbatim-string-literal production from the C# grammar. See issue 93.
4303 fallthroughStylePatterns.push(
4304 [PR_STRING, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]);
4306 var hc = options['hashComments'];
4308 if (options['cStyleComments']) {
4309 if (hc > 1) { // multiline hash comments
4310 shortcutStylePatterns.push(
4311 [PR_COMMENT, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, '#']);
4313 // Stop C preprocessor declarations at an unclosed open comment
4314 shortcutStylePatterns.push(
4315 [PR_COMMENT, /^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,
4318 // #include <stdio.h>
4319 fallthroughStylePatterns.push(
4321 /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,
4324 shortcutStylePatterns.push([PR_COMMENT, /^#[^\r\n]*/, null, '#']);
4327 if (options['cStyleComments']) {
4328 fallthroughStylePatterns.push([PR_COMMENT, /^\/\/[^\r\n]*/, null]);
4329 fallthroughStylePatterns.push(
4330 [PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
4332 if (options['regexLiterals']) {
4336 var REGEX_LITERAL = (
4337 // A regular expression literal starts with a slash that is
4338 // not followed by * or / so that it is not confused with
4341 // and then contains any number of raw characters,
4342 + '(?:[^/\\x5B\\x5C]'
4343 // escape sequences (\x5C),
4345 // or non-nesting character sets (\x5B\x5D);
4346 + '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
4347 // finally closed by a /.
4349 fallthroughStylePatterns.push(
4351 new RegExp('^' + REGEXP_PRECEDER_PATTERN + '(' + REGEX_LITERAL + ')')
4355 var types = options['types'];
4357 fallthroughStylePatterns.push([PR_TYPE, types]);
4360 var keywords = ("" + options['keywords']).replace(/^ | $/g, '');
4361 if (keywords.length) {
4362 fallthroughStylePatterns.push(
4364 new RegExp('^(?:' + keywords.replace(/[\s,]+/g, '|') + ')\\b'),
4368 shortcutStylePatterns.push([PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0']);
4371 // The Bash man page says
4373 // A word is a sequence of characters considered as a single
4374 // unit by GRUB. Words are separated by metacharacters,
4375 // which are the following plus space, tab, and newline: { }
4379 // A word beginning with # causes that word and all remaining
4380 // characters on that line to be ignored.
4382 // which means that only a '#' after /(?:^|[{}|&$;<>\s])/ starts a
4383 // comment but empirically
4391 // so /(?:^|[|&;<>\s])/ is more appropriate.
4393 // http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC3
4394 // suggests that this definition is compatible with a
4395 // default mode that tries to use a single token definition
4396 // to recognize both bash/python style comments and C
4397 // preprocessor directives.
4399 // This definition of punctuation does not include # in the list of
4400 // follow-on exclusions, so # will not be broken before if preceeded
4401 // by a punctuation character. We could try to exclude # after
4402 // [|&;<>] but that doesn't seem to cause many major problems.
4403 // If that does turn out to be a problem, we should change the below
4404 // when hc is truthy to include # in the run of punctuation characters
4405 // only when not followint [|&;<>].
4406 /^.[^\s\w\.$@\'\"\`\/\\]*/;
4408 fallthroughStylePatterns.push(
4409 // TODO(mikesamuel): recognize non-latin letters and numerals in idents
4410 [PR_LITERAL, /^@[a-z_$][a-z_$@0-9]*/i, null],
4411 [PR_TYPE, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null],
4412 [PR_PLAIN, /^[a-z_$][a-z_$@0-9]*/i, null],
4418 // or an octal or decimal number,
4419 + '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
4420 // possibly in scientific notation
4421 + '(?:e[+\\-]?\\d+)?'
4423 // with an optional modifier like UL for unsigned long
4425 null, '0123456789'],
4426 // Don't treat escaped quotes in bash as starting strings. See issue 144.
4427 [PR_PLAIN, /^\\[\s\S]?/, null],
4428 [PR_PUNCTUATION, punctuation, null]);
4430 return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
4433 var decorateSource = sourceDecorator({
4434 'keywords': ALL_KEYWORDS,
4435 'hashComments': true,
4436 'cStyleComments': true,
4437 'multiLineStrings': true,
4438 'regexLiterals': true
4442 * Given a DOM subtree, wraps it in a list, and puts each line into its own
4445 * @param {Node} node modified in place. Its content is pulled into an
4446 * HTMLOListElement, and each line is moved into a separate list item.
4447 * This requires cloning elements, so the input might not have unique
4448 * IDs after numbering.
4449 * @param {boolean} isPreformatted true iff white-space in text nodes should
4450 * be treated as significant.
4452 function numberLines(node, opt_startLineNum, isPreformatted) {
4453 var nocode = /(?:^|\s)nocode(?:\s|$)/;
4454 var lineBreak = /\r\n?|\n/;
4456 var document = node.ownerDocument;
4458 var li = document.createElement('li');
4459 while (node.firstChild) {
4460 li.appendChild(node.firstChild);
4462 // An array of lines. We split below, so this is initialized to one
4464 var listItems = [li];
4466 function walk(node) {
4467 switch (node.nodeType) {
4469 if (nocode.test(node.className)) { break; }
4470 if ('br' === node.nodeName) {
4472 // Discard the <BR> since it is now flush against a </LI>.
4473 if (node.parentNode) {
4474 node.parentNode.removeChild(node);
4477 for (var child = node.firstChild; child; child = child.nextSibling) {
4482 case 3: case 4: // Text
4483 if (isPreformatted) {
4484 var text = node.nodeValue;
4485 var match = text.match(lineBreak);
4487 var firstLine = text.substring(0, match.index);
4488 node.nodeValue = firstLine;
4489 var tail = text.substring(match.index + match[0].length);
4491 var parent = node.parentNode;
4492 parent.insertBefore(
4493 document.createTextNode(tail), node.nextSibling);
4497 // Don't leave blank text nodes in the DOM.
4498 node.parentNode.removeChild(node);
4506 // Split a line after the given node.
4507 function breakAfter(lineEndNode) {
4508 // If there's nothing to the right, then we can skip ending the line
4509 // here, and move root-wards since splitting just before an end-tag
4510 // would require us to create a bunch of empty copies.
4511 while (!lineEndNode.nextSibling) {
4512 lineEndNode = lineEndNode.parentNode;
4513 if (!lineEndNode) { return; }
4516 function breakLeftOf(limit, copy) {
4517 // Clone shallowly if this node needs to be on both sides of the break.
4518 var rightSide = copy ? limit.cloneNode(false) : limit;
4519 var parent = limit.parentNode;
4521 // We clone the parent chain.
4522 // This helps us resurrect important styling elements that cross lines.
4523 // E.g. in <i>Foo<br>Bar</i>
4524 // should be rewritten to <li><i>Foo</i></li><li><i>Bar</i></li>.
4525 var parentClone = breakLeftOf(parent, 1);
4526 // Move the clone and everything to the right of the original
4527 // onto the cloned parent.
4528 var next = limit.nextSibling;
4529 parentClone.appendChild(rightSide);
4530 for (var sibling = next; sibling; sibling = next) {
4531 next = sibling.nextSibling;
4532 parentClone.appendChild(sibling);
4538 var copiedListItem = breakLeftOf(lineEndNode.nextSibling, 0);
4540 // Walk the parent chain until we reach an unattached LI.
4542 // Check nodeType since IE invents document fragments.
4543 (parent = copiedListItem.parentNode) && parent.nodeType === 1;) {
4544 copiedListItem = parent;
4546 // Put it on the list of lines for later processing.
4547 listItems.push(copiedListItem);
4550 // Split lines while there are lines left to split.
4551 for (var i = 0; // Number of lines that have been split so far.
4552 i < listItems.length; // length updated by breakAfter calls.
4557 // Make sure numeric indices show correctly.
4558 if (opt_startLineNum === (opt_startLineNum|0)) {
4559 listItems[0].setAttribute('value', opt_startLineNum);
4562 var ol = document.createElement('ol');
4563 ol.className = 'linenums';
4564 var offset = Math.max(0, ((opt_startLineNum - 1 /* zero index */)) | 0) || 0;
4565 for (var i = 0, n = listItems.length; i < n; ++i) {
4567 // Stick a class on the LIs so that stylesheets can
4568 // color odd/even rows, or any other row pattern that
4569 // is co-prime with 10.
4570 li.className = 'L' + ((i + offset) % 10);
4571 if (!li.firstChild) {
4572 li.appendChild(document.createTextNode('\xA0'));
4577 node.appendChild(ol);
4581 * Breaks {@code job.sourceCode} around style boundaries in
4582 * {@code job.decorations} and modifies {@code job.sourceNode} in place.
4583 * @param {Object} job like <pre>{
4584 * sourceCode: {string} source as plain text,
4585 * spans: {Array.<number|Node>} alternating span start indices into source
4586 * and the text node or element (e.g. {@code <BR>}) corresponding to that
4588 * decorations: {Array.<number|string} an array of style classes preceded
4589 * by the position at which they start in job.sourceCode in order
4593 function recombineTagsAndDecorations(job) {
4594 var isIE8OrEarlier = /\bMSIE\s(\d+)/.exec(navigator.userAgent);
4595 isIE8OrEarlier = isIE8OrEarlier && +isIE8OrEarlier[1] <= 8;
4596 var newlineRe = /\n/g;
4598 var source = job.sourceCode;
4599 var sourceLength = source.length;
4600 // Index into source after the last code-unit recombined.
4601 var sourceIndex = 0;
4603 var spans = job.spans;
4604 var nSpans = spans.length;
4605 // Index into spans after the last span which ends at or before sourceIndex.
4608 var decorations = job.decorations;
4609 var nDecorations = decorations.length;
4610 // Index into decorations after the last decoration which ends at or before
4612 var decorationIndex = 0;
4614 // Remove all zero-length decorations.
4615 decorations[nDecorations] = sourceLength;
4617 for (i = decPos = 0; i < nDecorations;) {
4618 if (decorations[i] !== decorations[i + 2]) {
4619 decorations[decPos++] = decorations[i++];
4620 decorations[decPos++] = decorations[i++];
4625 nDecorations = decPos;
4627 // Simplify decorations.
4628 for (i = decPos = 0; i < nDecorations;) {
4629 var startPos = decorations[i];
4630 // Conflate all adjacent decorations that use the same style.
4631 var startDec = decorations[i + 1];
4633 while (end + 2 <= nDecorations && decorations[end + 1] === startDec) {
4636 decorations[decPos++] = startPos;
4637 decorations[decPos++] = startDec;
4641 nDecorations = decorations.length = decPos;
4643 var sourceNode = job.sourceNode;
4646 oldDisplay = sourceNode.style.display;
4647 sourceNode.style.display = 'none';
4650 var decoration = null;
4651 while (spanIndex < nSpans) {
4652 var spanStart = spans[spanIndex];
4653 var spanEnd = spans[spanIndex + 2] || sourceLength;
4655 var decEnd = decorations[decorationIndex + 2] || sourceLength;
4657 var end = Math.min(spanEnd, decEnd);
4659 var textNode = spans[spanIndex + 1];
4661 if (textNode.nodeType !== 1 // Don't muck with <BR>s or <LI>s
4662 // Don't introduce spans around empty text nodes.
4663 && (styledText = source.substring(sourceIndex, end))) {
4664 // This may seem bizarre, and it is. Emitting LF on IE causes the
4665 // code to display with spaces instead of line breaks.
4666 // Emitting Windows standard issue linebreaks (CRLF) causes a blank
4667 // space to appear at the beginning of every line but the first.
4668 // Emitting an old Mac OS 9 line separator makes everything spiffy.
4669 if (isIE8OrEarlier) {
4670 styledText = styledText.replace(newlineRe, '\r');
4672 textNode.nodeValue = styledText;
4673 var document = textNode.ownerDocument;
4674 var span = document.createElement('span');
4675 span.className = decorations[decorationIndex + 1];
4676 var parentNode = textNode.parentNode;
4677 parentNode.replaceChild(span, textNode);
4678 span.appendChild(textNode);
4679 if (sourceIndex < spanEnd) { // Split off a text node.
4680 spans[spanIndex + 1] = textNode
4681 // TODO: Possibly optimize by using '' if there's no flicker.
4682 = document.createTextNode(source.substring(end, spanEnd));
4683 parentNode.insertBefore(textNode, span.nextSibling);
4689 if (sourceIndex >= spanEnd) {
4692 if (sourceIndex >= decEnd) {
4693 decorationIndex += 2;
4698 sourceNode.style.display = oldDisplay;
4704 /** Maps language-specific file extensions to handlers. */
4705 var langHandlerRegistry = {};
4706 /** Register a language handler for the given file extensions.
4707 * @param {function (Object)} handler a function from source code to a list
4708 * of decorations. Takes a single argument job which describes the
4709 * state of the computation. The single parameter has the form
4711 * sourceCode: {string} as plain text.
4712 * decorations: {Array.<number|string>} an array of style classes
4713 * preceded by the position at which they start in
4714 * job.sourceCode in order.
4715 * The language handler should assigned this field.
4716 * basePos: {int} the position of source in the larger source chunk.
4717 * All positions in the output decorations array are relative
4718 * to the larger source chunk.
4720 * @param {Array.<string>} fileExtensions
4722 function registerLangHandler(handler, fileExtensions) {
4723 for (var i = fileExtensions.length; --i >= 0;) {
4724 var ext = fileExtensions[i];
4725 if (!langHandlerRegistry.hasOwnProperty(ext)) {
4726 langHandlerRegistry[ext] = handler;
4727 } else if (win['console']) {
4728 console['warn']('cannot override language handler %s', ext);
4732 function langHandlerForExtension(extension, source) {
4733 if (!(extension && langHandlerRegistry.hasOwnProperty(extension))) {
4734 // Treat it as markup if the first non whitespace character is a < and
4735 // the last non-whitespace character is a >.
4736 extension = /^\s*</.test(source)
4740 return langHandlerRegistry[extension];
4742 registerLangHandler(decorateSource, ['default-code']);
4743 registerLangHandler(
4747 [PR_PLAIN, /^[^<?]+/],
4748 [PR_DECLARATION, /^<!\w[^>]*(?:>|$)/],
4749 [PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/],
4750 // Unescaped content in an unknown language
4751 ['lang-', /^<\?([\s\S]+?)(?:\?>|$)/],
4752 ['lang-', /^<%([\s\S]+?)(?:%>|$)/],
4753 [PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/],
4754 ['lang-', /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
4755 // Unescaped content in javascript. (Or possibly vbscript).
4756 ['lang-js', /^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],
4757 // Contains unescaped stylesheet content
4758 ['lang-css', /^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],
4759 ['lang-in.tag', /^(<\/?[a-z][^<>]*>)/i]
4761 ['default-markup', 'htm', 'html', 'mxml', 'xhtml', 'xml', 'xsl']);
4762 registerLangHandler(
4765 [PR_PLAIN, /^[\s]+/, null, ' \t\r\n'],
4766 [PR_ATTRIB_VALUE, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, '\"\'']
4769 [PR_TAG, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],
4770 [PR_ATTRIB_NAME, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],
4771 ['lang-uq.val', /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],
4772 [PR_PUNCTUATION, /^[=<>\/]+/],
4773 ['lang-js', /^on\w+\s*=\s*\"([^\"]+)\"/i],
4774 ['lang-js', /^on\w+\s*=\s*\'([^\']+)\'/i],
4775 ['lang-js', /^on\w+\s*=\s*([^\"\'>\s]+)/i],
4776 ['lang-css', /^style\s*=\s*\"([^\"]+)\"/i],
4777 ['lang-css', /^style\s*=\s*\'([^\']+)\'/i],
4778 ['lang-css', /^style\s*=\s*([^\"\'>\s]+)/i]
4781 registerLangHandler(
4782 createSimpleLexer([], [[PR_ATTRIB_VALUE, /^[\s\S]+/]]), ['uq.val']);
4783 registerLangHandler(sourceDecorator({
4784 'keywords': CPP_KEYWORDS,
4785 'hashComments': true,
4786 'cStyleComments': true,
4788 }), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
4789 registerLangHandler(sourceDecorator({
4790 'keywords': 'null,true,false'
4792 registerLangHandler(sourceDecorator({
4793 'keywords': CSHARP_KEYWORDS,
4794 'hashComments': true,
4795 'cStyleComments': true,
4796 'verbatimStrings': true,
4799 registerLangHandler(sourceDecorator({
4800 'keywords': JAVA_KEYWORDS,
4801 'cStyleComments': true
4803 registerLangHandler(sourceDecorator({
4804 'keywords': SH_KEYWORDS,
4805 'hashComments': true,
4806 'multiLineStrings': true
4807 }), ['bsh', 'csh', 'sh']);
4808 registerLangHandler(sourceDecorator({
4809 'keywords': PYTHON_KEYWORDS,
4810 'hashComments': true,
4811 'multiLineStrings': true,
4812 'tripleQuotedStrings': true
4814 registerLangHandler(sourceDecorator({
4815 'keywords': PERL_KEYWORDS,
4816 'hashComments': true,
4817 'multiLineStrings': true,
4818 'regexLiterals': true
4819 }), ['perl', 'pl', 'pm']);
4820 registerLangHandler(sourceDecorator({
4821 'keywords': RUBY_KEYWORDS,
4822 'hashComments': true,
4823 'multiLineStrings': true,
4824 'regexLiterals': true
4826 registerLangHandler(sourceDecorator({
4827 'keywords': JSCRIPT_KEYWORDS,
4828 'cStyleComments': true,
4829 'regexLiterals': true
4831 registerLangHandler(sourceDecorator({
4832 'keywords': COFFEE_KEYWORDS,
4833 'hashComments': 3, // ### style block comments
4834 'cStyleComments': true,
4835 'multilineStrings': true,
4836 'tripleQuotedStrings': true,
4837 'regexLiterals': true
4839 registerLangHandler(
4840 createSimpleLexer([], [[PR_STRING, /^[\s\S]+/]]), ['regex']);
4842 function applyDecorator(job) {
4843 var opt_langExtension = job.langExtension;
4846 // Extract tags, and convert the source code to plain text.
4847 var sourceAndSpans = extractSourceSpans(job.sourceNode, job.pre);
4848 /** Plain text. @type {string} */
4849 var source = sourceAndSpans.sourceCode;
4850 job.sourceCode = source;
4851 job.spans = sourceAndSpans.spans;
4854 // Apply the appropriate language handler
4855 langHandlerForExtension(opt_langExtension, source)(job);
4857 // Integrate the decorations and tags back into the source code,
4858 // modifying the sourceNode in place.
4859 recombineTagsAndDecorations(job);
4861 if (win['console']) {
4862 console['log'](e && e['stack'] ? e['stack'] : e);
4868 * @param sourceCodeHtml {string} The HTML to pretty print.
4869 * @param opt_langExtension {string} The language name to use.
4870 * Typically, a filename extension like 'cpp' or 'java'.
4871 * @param opt_numberLines {number|boolean} True to number lines,
4872 * or the 1-indexed number of the first line in sourceCodeHtml.
4874 function prettyPrintOne(sourceCodeHtml, opt_langExtension, opt_numberLines) {
4875 var container = document.createElement('pre');
4876 // This could cause images to load and onload listeners to fire.
4877 // E.g. <img onerror="alert(1337)" src="nosuchimage.png">.
4878 // We assume that the inner HTML is from a trusted source.
4879 container.innerHTML = sourceCodeHtml;
4880 if (opt_numberLines) {
4881 numberLines(container, opt_numberLines, true);
4885 langExtension: opt_langExtension,
4886 numberLines: opt_numberLines,
4887 sourceNode: container,
4890 applyDecorator(job);
4891 return container.innerHTML;
4894 function prettyPrint(opt_whenDone) {
4895 function byTagName(tn) { return document.getElementsByTagName(tn); }
4896 // fetch a list of nodes to rewrite
4897 var codeSegments = [byTagName('pre'), byTagName('code'), byTagName('xmp')];
4899 for (var i = 0; i < codeSegments.length; ++i) {
4900 for (var j = 0, n = codeSegments[i].length; j < n; ++j) {
4901 elements.push(codeSegments[i][j]);
4904 codeSegments = null;
4907 if (!clock['now']) {
4908 clock = { 'now': function () { return +(new Date); } };
4911 // The loop is broken into a series of continuations to make sure that we
4912 // don't make the browser unresponsive when rewriting a large page.
4914 var prettyPrintingJob;
4916 var langExtensionRe = /\blang(?:uage)?-([\w.]+)(?!\S)/;
4917 var prettyPrintRe = /\bprettyprint\b/;
4918 var prettyPrintedRe = /\bprettyprinted\b/;
4919 var preformattedTagNameRe = /pre|xmp/i;
4920 var codeRe = /^code$/i;
4921 var preCodeXmpRe = /^(?:pre|code|xmp)$/i;
4924 var endTime = (win['PR_SHOULD_USE_CONTINUATION'] ?
4925 clock['now']() + 250 /* ms */ :
4927 for (; k < elements.length && clock['now']() < endTime; k++) {
4928 var cs = elements[k];
4929 var className = cs.className;
4930 if (prettyPrintRe.test(className)
4931 // Don't redo this if we've already done it.
4932 // This allows recalling pretty print to just prettyprint elements
4933 // that have been added to the page since last call.
4934 && !prettyPrintedRe.test(className)) {
4936 // make sure this is not nested in an already prettified element
4938 for (var p = cs.parentNode; p; p = p.parentNode) {
4940 if (preCodeXmpRe.test(tn)
4941 && p.className && prettyPrintRe.test(p.className)) {
4947 // Mark done. If we fail to prettyprint for whatever reason,
4948 // we shouldn't try again.
4949 cs.className += ' prettyprinted';
4951 // If the classes includes a language extensions, use it.
4952 // Language extensions can be specified like
4953 // <pre class="prettyprint lang-cpp">
4954 // the language extension "cpp" is used to find a language handler
4955 // as passed to PR.registerLangHandler.
4956 // HTML5 recommends that a language be specified using "language-"
4957 // as the prefix instead. Google Code Prettify supports both.
4958 // http://dev.w3.org/html5/spec-author-view/the-code-element.html
4959 var langExtension = className.match(langExtensionRe);
4960 // Support <pre class="prettyprint"><code class="language-c">
4962 if (!langExtension && (wrapper = childContentWrapper(cs))
4963 && codeRe.test(wrapper.tagName)) {
4964 langExtension = wrapper.className.match(langExtensionRe);
4967 if (langExtension) { langExtension = langExtension[1]; }
4970 if (preformattedTagNameRe.test(cs.tagName)) {
4973 var currentStyle = cs['currentStyle'];
4976 ? currentStyle['whiteSpace']
4977 : (document.defaultView
4978 && document.defaultView.getComputedStyle)
4979 ? document.defaultView.getComputedStyle(cs, null)
4980 .getPropertyValue('white-space')
4982 preformatted = whitespace
4983 && 'pre' === whitespace.substring(0, 3);
4986 // Look for a class like linenums or linenums:<n> where <n> is the
4987 // 1-indexed number of the first line.
4988 var lineNums = cs.className.match(/\blinenums\b(?::(\d+))?/);
4990 ? lineNums[1] && lineNums[1].length ? +lineNums[1] : true
4992 if (lineNums) { numberLines(cs, lineNums, preformatted); }
4994 // do the pretty printing
4995 prettyPrintingJob = {
4996 langExtension: langExtension,
4998 numberLines: lineNums,
5001 applyDecorator(prettyPrintingJob);
5005 if (k < elements.length) {
5006 // finish up in a continuation
5007 setTimeout(doWork, 250);
5008 } else if (opt_whenDone) {
5017 * Contains functions for creating and registering new language handlers.
5020 var PR = win['PR'] = {
5021 'createSimpleLexer': createSimpleLexer,
5022 'registerLangHandler': registerLangHandler,
5023 'sourceDecorator': sourceDecorator,
5024 'PR_ATTRIB_NAME': PR_ATTRIB_NAME,
5025 'PR_ATTRIB_VALUE': PR_ATTRIB_VALUE,
5026 'PR_COMMENT': PR_COMMENT,
5027 'PR_DECLARATION': PR_DECLARATION,
5028 'PR_KEYWORD': PR_KEYWORD,
5029 'PR_LITERAL': PR_LITERAL,
5030 'PR_NOCODE': PR_NOCODE,
5031 'PR_PLAIN': PR_PLAIN,
5032 'PR_PUNCTUATION': PR_PUNCTUATION,
5033 'PR_SOURCE': PR_SOURCE,
5034 'PR_STRING': PR_STRING,
5037 'prettyPrintOne': win['prettyPrintOne'] = prettyPrintOne,
5038 'prettyPrint': win['prettyPrint'] = prettyPrint
5041 // Make PR available via the Asynchronous Module Definition (AMD) API.
5042 // Per https://github.com/amdjs/amdjs-api/wiki/AMD:
5043 // The Asynchronous Module Definition (AMD) API specifies a
5044 // mechanism for defining modules such that the module and its
5045 // dependencies can be asynchronously loaded.
5047 // To allow a clear indicator that a global define function (as
5048 // needed for script src browser loading) conforms to the AMD API,
5049 // any global define function SHOULD have a property called "amd"
5050 // whose value is an object. This helps avoid conflict with any
5051 // other existing JavaScript code that could have defined a define()
5052 // function that does not conform to the AMD API.
5053 if (typeof define === "function" && define['amd']) {
5054 define(function () {
5061 <script>(function(scope) {
5063 var ContextFreeParser = {
5064 parse: function(text) {
5068 var subCurrent = {};
5070 var scriptDocCommentClause = '\\/\\*\\*([\\s\\S]*?)\\*\\/';
5071 var htmlDocCommentClause = '<!--([\\s\\S]*?)-->';
5073 // matches text between /** and */ inclusive and <!-- and --> inclusive
5074 var docCommentRegex = new RegExp(scriptDocCommentClause + '|' + htmlDocCommentClause, 'g');
5076 // acquire all script doc comments
5077 var docComments = text.match(docCommentRegex) || [];
5079 // each match represents a single block of doc comments
5080 docComments.forEach(function(m) {
5081 // unify line ends, remove all comment characters, split into individual lines
5082 var lines = m.replace(/\r\n/g, '\n').replace(/^\s*\/\*\*|^\s*\*\/|^\s*\* ?|^\s*\<\!-\-|^s*\-\-\>/gm, '').split('\n');
5084 // pragmas (@-rules) must occur on a line by themselves
5086 // filter lines whose first non-whitespace character is @ into the pragma list
5087 // (and out of the `lines` array)
5088 lines = lines.filter(function(l) {
5089 var m = l.match(/\s*@([\w-]*) (.*)/);
5096 // collect all other text into a single block
5097 var code = lines.join('\n');
5100 pragmas.forEach(function(m) {
5101 var pragma = m[1], content = m[2];
5104 // currently all entities are either @class or @element
5111 entities.push(current);
5114 // an entity may have these describable sub-features
5123 var label = pragma == 'property' ? 'properties' : pragma + 's';
5124 makePragma(current, label, subCurrent);
5127 // sub-feature pragmas
5130 subCurrent[pragma] = content;
5135 current[pragma] = content;
5140 // utility function, yay hoisting
5141 function makePragma(object, pragma, content) {
5145 p$[pragma] = p = [];
5152 if (entities.length === 0) {
5153 entities.push({name: 'Entity', description: '**Undocumented**'});
5159 if (typeof module !== 'undefined' && module.exports) {
5160 module.exports = ContextFreeParser;
5162 scope.ContextFreeParser = ContextFreeParser;
5167 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
5168 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5169 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5170 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
5171 Code distributed by Google as part of the polymer project is also
5172 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
5176 @group Polymer Core Elements
5178 The `core-ajax` element exposes `XMLHttpRequest` functionality.
5182 url="http://gdata.youtube.com/feeds/api/videos/"
5183 params='{"alt":"json", "q":"chrome"}'
5185 on-core-response="{{handleResponse}}"></core-ajax>
5187 With `auto` set to `true`, the element performs a request whenever
5188 its `url` or `params` properties are changed.
5190 Note: The `params` attribute must be double quoted JSON.
5192 You can trigger a request explicitly by calling `go` on the
5200 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
5201 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5202 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5203 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
5204 Code distributed by Google as part of the polymer project is also
5205 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
5209 * @group Polymer Core Elements
5211 * core-xhr can be used to perform XMLHttpRequests.
5213 * <core-xhr id="xhr"></core-xhr>
5215 * this.$.xhr.request({url: url, params: params, callback: callback});
5223 <polymer-element name="core-xhr" hidden assetpath="../core-ajax/">
5227 Polymer('core-xhr', {
5230 * Sends a HTTP request to the server and returns the XHR object.
5233 * @param {Object} inOptions
5234 * @param {String} inOptions.url The url to which the request is sent.
5235 * @param {String} inOptions.method The HTTP method to use, default is GET.
5236 * @param {boolean} inOptions.sync By default, all requests are sent asynchronously. To send synchronous requests, set to true.
5237 * @param {Object} inOptions.params Data to be sent to the server.
5238 * @param {Object} inOptions.body The content for the request body for POST method.
5239 * @param {Object} inOptions.headers HTTP request headers.
5240 * @param {String} inOptions.responseType The response type. Default is 'text'.
5241 * @param {boolean} inOptions.withCredentials Whether or not to send credentials on the request. Default is false.
5242 * @param {Object} inOptions.callback Called when request is completed.
5243 * @returns {Object} XHR object.
5245 request: function(options) {
5246 var xhr = new XMLHttpRequest();
5247 var url = options.url;
5248 var method = options.method || 'GET';
5249 var async = !options.sync;
5251 var params = this.toQueryString(options.params);
5252 if (params && method == 'GET') {
5253 url += (url.indexOf('?') > 0 ? '&' : '?') + params;
5255 var xhrParams = this.isBodyMethod(method) ? (options.body || params) : null;
5257 xhr.open(method, url, async);
5258 if (options.responseType) {
5259 xhr.responseType = options.responseType;
5261 if (options.withCredentials) {
5262 xhr.withCredentials = true;
5264 this.makeReadyStateHandler(xhr, options.callback);
5265 this.setRequestHeaders(xhr, options.headers);
5266 xhr.send(xhrParams);
5268 xhr.onreadystatechange(xhr);
5273 toQueryString: function(params) {
5275 for (var n in params) {
5277 n = encodeURIComponent(n);
5278 r.push(v == null ? n : (n + '=' + encodeURIComponent(v)));
5283 isBodyMethod: function(method) {
5284 return this.bodyMethods[(method || '').toUpperCase()];
5293 makeReadyStateHandler: function(xhr, callback) {
5294 xhr.onreadystatechange = function() {
5295 if (xhr.readyState == 4) {
5296 callback && callback.call(null, xhr.response, xhr);
5301 setRequestHeaders: function(xhr, headers) {
5303 for (var name in headers) {
5304 xhr.setRequestHeader(name, headers[name]);
5315 <polymer-element name="core-ajax" attributes="url handleAs auto params response method headers body contentType withCredentials" assetpath="../core-ajax/">
5318 Polymer('core-ajax', {
5320 * Fired when a response is received.
5322 * @event core-response
5326 * Fired when an error is received.
5332 * Fired whenever a response or an error is received.
5334 * @event core-complete
5338 * The URL target of the request.
5347 * Specifies what data to store in the `response` property, and
5348 * to deliver as `event.response` in `response` events.
5352 * `text`: uses `XHR.responseText`.
5354 * `xml`: uses `XHR.responseXML`.
5356 * `json`: uses `XHR.responseText` parsed as JSON.
5358 * `arraybuffer`: uses `XHR.response`.
5360 * `blob`: uses `XHR.response`.
5362 * `document`: uses `XHR.response`.
5364 * @attribute handleAs
5371 * If true, automatically performs an Ajax request when either `url` or `params` changes.
5380 * Parameters to send to the specified URL, as JSON.
5383 * @type string (JSON)
5389 * Returns the response object.
5391 * @attribute response
5398 * The HTTP method to use such as 'GET', 'POST', 'PUT', or 'DELETE'.
5408 * HTTP request headers to send.
5414 * url="http://somesite.com"
5415 * headers='{"X-Requested-With": "XMLHttpRequest"}'
5417 * on-core-response="{{handleResponse}}"></core-ajax>
5419 * @attribute headers
5426 * Optional raw body content to send when method === "POST".
5430 * <core-ajax method="POST" auto url="http://somesite.com"
5431 * body='{"foo":1, "bar":2}'>
5441 * Content type to use when sending data.
5443 * @attribute contentType
5445 * @default 'application/x-www-form-urlencoded'
5447 contentType: 'application/x-www-form-urlencoded',
5450 * Set the withCredentials flag on the request.
5452 * @attribute withCredentials
5456 withCredentials: false,
5459 * Additional properties to send to core-xhr.
5461 * Can be set to an object containing default properties
5462 * to send as arguments to the `core-xhr.request()` method
5463 * which implements the low-level communication.
5472 this.xhr = document.createElement('core-xhr');
5475 receive: function(response, xhr) {
5476 if (this.isSuccess(xhr)) {
5477 this.processResponse(xhr);
5484 isSuccess: function(xhr) {
5485 var status = xhr.status || 0;
5486 return !status || (status >= 200 && status < 300);
5489 processResponse: function(xhr) {
5490 var response = this.evalResponse(xhr);
5491 this.response = response;
5492 this.fire('core-response', {response: response, xhr: xhr});
5495 error: function(xhr) {
5496 var response = xhr.status + ': ' + xhr.responseText;
5497 this.fire('core-error', {response: response, xhr: xhr});
5500 complete: function(xhr) {
5501 this.fire('core-complete', {response: xhr.status, xhr: xhr});
5504 evalResponse: function(xhr) {
5505 return this[(this.handleAs || 'text') + 'Handler'](xhr);
5508 xmlHandler: function(xhr) {
5509 return xhr.responseXML;
5512 textHandler: function(xhr) {
5513 return xhr.responseText;
5516 jsonHandler: function(xhr) {
5517 var r = xhr.responseText;
5519 return JSON.parse(r);
5525 documentHandler: function(xhr) {
5526 return xhr.response;
5529 blobHandler: function(xhr) {
5530 return xhr.response;
5533 arraybufferHandler: function(xhr) {
5534 return xhr.response;
5537 urlChanged: function() {
5538 if (!this.handleAs) {
5539 var ext = String(this.url).split('.').pop();
5542 this.handleAs = 'json';
5549 paramsChanged: function() {
5553 autoChanged: function() {
5557 // TODO(sorvell): multiple side-effects could call autoGo
5558 // during one micro-task, use a job to have only one action
5560 autoGo: function() {
5562 this.goJob = this.job(this.goJob, this.go, 0);
5567 * Performs an Ajax request to the specified URL.
5572 var args = this.xhrArgs || {};
5573 // TODO(sjmiles): we may want XHR to default to POST if body is set
5574 args.body = this.body || args.body;
5575 args.params = this.params || args.params;
5576 if (args.params && typeof(args.params) == 'string') {
5577 args.params = JSON.parse(args.params);
5579 args.headers = this.headers || args.headers || {};
5580 if (args.headers && typeof(args.headers) == 'string') {
5581 args.headers = JSON.parse(args.headers);
5583 if (this.contentType) {
5584 args.headers['content-type'] = this.contentType;
5586 if (this.handleAs === 'arraybuffer' || this.handleAs === 'blob' ||
5587 this.handleAs === 'document') {
5588 args.responseType = this.handleAs;
5590 args.withCredentials = this.withCredentials;
5591 args.callback = this.receive.bind(this);
5592 args.url = this.url;
5593 args.method = this.method;
5594 return args.url && this.xhr.request(args);
5604 Scrapes source documentation data from input text or url.
5606 @class context-free-parser
5608 <polymer-element name="context-free-parser" attributes="url text data" assetpath="../context-free-parser/">
5611 <core-ajax url="{{url}}" response="{{text}}" auto=""></core-ajax>
5616 Polymer('context-free-parser', {
5620 textChanged: function() {
5622 var entities = ContextFreeParser.parse(this.text);
5623 if (!entities || entities.length === 0) {
5625 {name: this.url.split('/').pop(), description: '**Undocumented**'}
5628 this.data = { classes: entities };
5632 dataChanged: function() {
5633 this.fire('data-ready');
5644 Displays formatted source documentation scraped from input urls.
5646 @element core-doc-page
5649 <polymer-element name="core-doc-page" attributes="data" assetpath="../core-doc-viewer/elements/">
5653 Set url to add documentation from that location to the view.
5696 /* font-size: 14px; */
5699 text-decoration: none;
5700 /* colors / effects */
5701 background-color: #999;
5702 box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.1);
5703 box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.1);
5707 display: inline-block;
5708 padding: 4px 12px 5px 12px;
5714 padding-bottom: 4px;
5715 border-bottom: 1px solid whitesmoke;
5719 margin-bottom: 40px;
5724 background-color: #f8f8f8;
5728 font-family: Consolas, monospace;
5729 border: 1px solid #ddd;
5730 background-color: #f8f8f8;
5737 white-space: pre-wrap;
5759 .attribute-box .details {
5760 background-color: #FFF9C4;
5762 border-bottom: 1px solid #D1CCA1;
5765 .attribute-box .ntitle {
5769 .attribute-box code {
5772 background-color: transparent;
5773 border-radius: none;
5778 .property-box .ntitle {
5782 .property-box code {
5785 background-color: transparent;
5786 border-radius: none;
5791 .property-box .details {
5792 background-color: lightblue;
5794 border-bottom: 1px solid #D1CCA1;
5800 .method-box .details {
5801 background-color: #F0F4C3;
5803 border-bottom: 1px solid #D1CCA1;
5806 .method-box .ntitle {
5807 background-color: #9E9D24;
5814 background-color: transparent;
5815 border-radius: none;
5823 .event-box .details {
5824 background-color: #B2DFDB;
5826 border-bottom: 1px solid #92B7B3;
5829 .event-box .ntitle {
5830 background-color: #009688;
5837 background-color: transparent;
5838 border-radius: none;
5845 font-family: "Source Code Pro",Monaco,Menlo,Consolas,"Courier New",monospace;
5848 pre .typ,pre .inline,.prettyprint .typ,.prettyprint .inline {
5851 pre .pun,.prettyprint .pun {
5854 pre .str,pre .string,.prettyprint .str,.prettyprint .string {
5857 pre .pln,.prettyprint .pln {
5860 pre .kwd,.prettyprint .kwd {
5863 pre .atn,pre .attribute-name,.prettyprint .atn,.prettyprint .attribute-name {
5866 pre .atv,pre .attribute-value,.prettyprint .atv,.prettyprint .attribute-value {
5869 pre .com,pre .comment,.prettyprint .com,.prettyprint .comment {
5873 <core-header-panel id="panel" mode="waterfall">
5876 <span style="margin: 0 72px;">{{data.name}}</span>
5879 <div class="main" on-marked-js-highlight="{{hilight}}">
5881 <h1 style="font-size: 52px; color: #E91E63;">
5886 <core-icon icon="home"></core-icon> <a href="{{data | homepageFilter}}">Home Page</a>
5889 <template if="{{data.extends}}">
5890 <section class="box">
5891 <div class="ntitle">Extends</div>
5892 <p><a href="#{{data.extends}}">{{data.extends}}</a></p>
5896 <template if="{{data.description}}">
5897 <section class="box top">
5898 <div class="ntitle">Summary</div>
5899 <marked-element text="{{data.description}}"></marked-element>
5903 <template if="{{data.attributes.length}}">
5904 <section class="box attribute-box">
5905 <div class="ntitle" style="background-color: #FFAB40; color: white;">Attributes</div>
5906 <template repeat="{{data.attributes}}">
5907 <div class="details">
5908 <div class="details-name">
5909 <p><code>{{name}}</code></p>
5911 <div class="details-info">
5912 <p><code>{{type}}</code></p>
5913 <marked-element text="{{description}}"></marked-element>
5920 <template if="{{data.properties.length}}">
5921 <section class="box property-box">
5922 <div class="ntitle" style="background-color: #4285F4; color: white;">Properties</div>
5923 <template repeat="{{data.properties}}">
5924 <div class="details">
5925 <div class="details-name">
5926 <p><code>{{name}}</code></p>
5928 <div class="details-info">
5929 <p><code>{{type}}</code></p>
5930 <marked-element text="{{description}}"></marked-element>
5937 <template if="{{data.events.length}}">
5938 <section class="box event-box">
5939 <div class="ntitle" style="color: white;">Events</div>
5940 <template repeat="{{data.events}}">
5941 <div class="details">
5942 <div class="details-name">
5943 <p><code>{{name}}</code></p>
5945 <div class="details-info">
5946 <marked-element text="{{description}}"></marked-element>
5953 <template if="{{data.methods.length}}">
5954 <section class="box method-box">
5955 <div class="ntitle" style="color: white;">Methods</div>
5956 <template repeat="{{data.methods}}">
5957 <div class="details">
5958 <div class="details-name">
5959 <p><code>{{name}}</code></p>
5961 <div class="details-info">
5962 <marked-element text="{{description}}"></marked-element>
5971 </core-header-panel>
5977 Polymer('core-doc-page', {
5979 hilight: function(event, detail, sender) {
5980 detail.code = prettyPrintOne((detail.code || '').replace(/</g,'<').replace(/>/g,'>'));
5983 homepageFilter: function(data) {
5987 if (!data.homepage || data.homepage === 'github.io') {
5988 return '//polymer.github.io/' + data.name;
5990 return data.homepage;
6004 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6005 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6006 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6007 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6008 Code distributed by Google as part of the polymer project is also
6009 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
6013 `core-menu` is a selector which styles to looks like a menu.
6015 <core-menu selected="0">
6016 <core-item icon="settings" label="Settings"></core-item>
6017 <core-item icon="dialog" label="Dialog"></core-item>
6018 <core-item icon="search" label="Search"></core-item>
6021 When an item is selected the `core-selected` class is added to it. The user can
6022 use the class to add more stylings to the selected item.
6024 core-item.core-selected {
6028 The `selectedItem` property references the selected item.
6030 <core-menu selected="0" selectedItem="{{item}}">
6031 <core-item icon="settings" label="Settings"></core-item>
6032 <core-item icon="dialog" label="Dialog"></core-item>
6033 <core-item icon="search" label="Search"></core-item>
6036 <div>selected label: {{item.label}}</div>
6038 The `core-select` event signals selection change.
6040 <core-menu selected="0" on-core-select="{{selectAction}}">
6041 <core-item icon="settings" label="Settings"></core-item>
6042 <core-item icon="dialog" label="Dialog"></core-item>
6043 <core-item icon="search" label="Search"></core-item>
6048 selectAction: function(e, detail) {
6049 if (detail.isSelected) {
6050 var selectedItem = detail.item;
6055 @group Polymer Core Elements
6057 @extends core-selector
6061 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6062 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6063 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6064 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6065 Code distributed by Google as part of the polymer project is also
6066 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
6070 @group Polymer Core Elements
6072 `<core-selector>` is used to manage a list of elements that can be selected.
6074 The attribute `selected` indicates which item element is being selected.
6075 The attribute `multi` indicates if multiple items can be selected at once.
6076 Tapping on the item element would fire `core-activate` event. Use
6077 `core-select` event to listen for selection changes.
6081 <core-selector selected="0">
6087 `<core-selector>` is not styled. Use the `core-selected` CSS class to style the selected element.
6090 .item.core-selected {
6096 <div class="item">Item 1</div>
6097 <div class="item">Item 2</div>
6098 <div class="item">Item 3</div>
6101 @element core-selector
6107 Fired when an item's selection state is changed. This event is fired both
6108 when an item is selected or deselected. The `isSelected` detail property
6109 contains the selection state.
6112 @param {Object} detail
6113 @param {boolean} detail.isSelected true for selection and false for deselection
6114 @param {Object} detail.item the item element
6117 Fired when an item element is tapped.
6119 @event core-activate
6120 @param {Object} detail
6121 @param {Object} detail.item the item element
6126 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6127 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6128 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6129 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6130 Code distributed by Google as part of the polymer project is also
6131 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
6134 @group Polymer Core Elements
6136 The `<core-selection>` element is used to manage selection state. It has no
6137 visual appearance and is typically used in conjunction with another element.
6138 For example, [core-selector](#core-selector)
6139 use a `<core-selection>` to manage selection.
6141 To mark an item as selected, call the `select(item)` method on
6142 `<core-selection>`. The item itself is an argument to this method.
6144 The `<core-selection>`element manages selection state for any given set of
6145 items. When an item is selected, the `core-select` event is fired.
6147 The attribute `multi` indicates if multiple items can be selected at once.
6151 <polymer-element name="selection-example">
6154 polyfill-next-selector { content: ':host > .selected'; }
6155 ::content > .selected {
6160 <ul on-tap="{{itemTapAction}}">
6163 <core-selection id="selection" multi
6164 on-core-select="{{selectAction}}"></core-selection>
6167 Polymer('selection-example', {
6168 itemTapAction: function(e, detail, sender) {
6169 this.$.selection.select(e.target);
6171 selectAction: function(e, detail, sender) {
6172 detail.item.classList.toggle('selected', detail.isSelected);
6182 </selection-example>
6184 @element core-selection
6188 Fired when an item's selection state is changed. This event is fired both
6189 when an item is selected or deselected. The `isSelected` detail property
6190 contains the selection state.
6193 @param {Object} detail
6194 @param {boolean} detail.isSelected true for selection and false for de-selection
6195 @param {Object} detail.item the item element
6199 <polymer-element name="core-selection" attributes="multi" hidden assetpath="../core-selection/">
6201 Polymer('core-selection', {
6203 * If true, multiple selections are allowed.
6214 this.selection = [];
6217 * Retrieves the selected item(s).
6218 * @method getSelection
6219 * @returns Returns the selected item(s). If the multi property is true,
6220 * getSelection will return an array, otherwise it will return
6221 * the selected item or undefined if there is no selection.
6223 getSelection: function() {
6224 return this.multi ? this.selection : this.selection[0];
6227 * Indicates if a given item is selected.
6228 * @method isSelected
6229 * @param {any} item The item whose selection state should be checked.
6230 * @returns Returns true if `item` is selected.
6232 isSelected: function(item) {
6233 return this.selection.indexOf(item) >= 0;
6235 setItemSelected: function(item, isSelected) {
6236 if (item !== undefined && item !== null) {
6238 this.selection.push(item);
6240 var i = this.selection.indexOf(item);
6242 this.selection.splice(i, 1);
6245 this.fire("core-select", {isSelected: isSelected, item: item});
6249 * Set the selection state for a given `item`. If the multi property
6250 * is true, then the selected state of `item` will be toggled; otherwise
6251 * the `item` will be selected.
6253 * @param {any} item: The item to select.
6255 select: function(item) {
6258 } else if (this.getSelection() !== item) {
6259 this.setItemSelected(this.getSelection(), false);
6260 this.setItemSelected(item, true);
6264 * Toggles the selection state for `item`.
6266 * @param {any} item: The item to toggle.
6268 toggle: function(item) {
6269 this.setItemSelected(item, !this.isSelected(item));
6276 <polymer-element name="core-selector" attributes="selected multi valueattr selectedClass selectedProperty selectedAttribute selectedItem selectedModel selectedIndex notap target itemsSelector activateEvent" assetpath="../core-selector/">
6279 <core-selection id="selection" multi="{{multi}}" on-core-select="{{selectionSelect}}"></core-selection>
6280 <content id="items" select="*"></content>
6285 Polymer('core-selector', {
6288 * Gets or sets the selected element. Default to use the index
6289 * of the item element.
6291 * If you want a specific attribute value of the element to be
6292 * used instead of index, set "valueattr" to that attribute name.
6296 * <core-selector valueattr="label" selected="foo">
6297 * <div label="foo"></div>
6298 * <div label="bar"></div>
6299 * <div label="zot"></div>
6302 * In multi-selection this should be an array of values.
6306 * <core-selector id="selector" valueattr="label" multi>
6307 * <div label="foo"></div>
6308 * <div label="bar"></div>
6309 * <div label="zot"></div>
6312 * this.$.selector.selected = ['foo', 'zot'];
6314 * @attribute selected
6321 * If true, multiple selections are allowed.
6330 * Specifies the attribute to be used for "selected" attribute.
6332 * @attribute valueattr
6339 * Specifies the CSS class to be used to add to the selected element.
6341 * @attribute selectedClass
6343 * @default 'core-selected'
6345 selectedClass: 'core-selected',
6348 * Specifies the property to be used to set on the selected element
6349 * to indicate its active state.
6351 * @attribute selectedProperty
6355 selectedProperty: '',
6358 * Specifies the attribute to set on the selected element to indicate
6361 * @attribute selectedAttribute
6365 selectedAttribute: 'active',
6368 * Returns the currently selected element. In multi-selection this returns
6369 * an array of selected elements.
6371 * @attribute selectedItem
6378 * In single selection, this returns the model associated with the
6381 * @attribute selectedModel
6385 selectedModel: null,
6388 * In single selection, this returns the selected index.
6390 * @attribute selectedIndex
6397 * The target element that contains items. If this is not set
6398 * core-selector is the container.
6407 * This can be used to query nodes from the target node to be used for
6408 * selection items. Note this only works if the 'target' property is set.
6412 * <core-selector target="{{$.myForm}}" itemsSelector="input[type=radio]"></core-selector>
6413 * <form id="myForm">
6414 * <label><input type="radio" name="color" value="red"> Red</label> <br>
6415 * <label><input type="radio" name="color" value="green"> Green</label> <br>
6416 * <label><input type="radio" name="color" value="blue"> Blue</label> <br>
6417 * <p>color = {{color}}</p>
6420 * @attribute itemSelector
6427 * The event that would be fired from the item element to indicate
6428 * it is being selected.
6430 * @attribute activateEvent
6434 activateEvent: 'tap',
6437 * Set this to true to disallow changing the selection via the
6447 this.activateListener = this.activateHandler.bind(this);
6448 this.observer = new MutationObserver(this.updateSelected.bind(this));
6458 var nodes = this.target !== this ? (this.itemsSelector ?
6459 this.target.querySelectorAll(this.itemsSelector) :
6460 this.target.children) : this.$.items.getDistributedNodes();
6461 return Array.prototype.filter.call(nodes || [], function(n) {
6462 return n && n.localName !== 'template';
6466 targetChanged: function(old) {
6468 this.removeListener(old);
6469 this.observer.disconnect();
6470 this.clearSelection();
6473 this.addListener(this.target);
6474 this.observer.observe(this.target, {childList: true});
6475 this.updateSelected();
6479 addListener: function(node) {
6480 node.addEventListener(this.activateEvent, this.activateListener);
6483 removeListener: function(node) {
6484 node.removeEventListener(this.activateEvent, this.activateListener);
6488 return this.$.selection.getSelection();
6491 selectedChanged: function() {
6492 this.updateSelected();
6495 updateSelected: function() {
6496 this.validateSelected();
6498 this.clearSelection();
6499 this.selected && this.selected.forEach(function(s) {
6500 this.valueToSelection(s);
6503 this.valueToSelection(this.selected);
6507 validateSelected: function() {
6508 // convert to an array for multi-selection
6509 if (this.multi && !Array.isArray(this.selected) &&
6510 this.selected !== null && this.selected !== undefined) {
6511 this.selected = [this.selected];
6515 clearSelection: function() {
6517 this.selection.slice().forEach(function(s) {
6518 this.$.selection.setItemSelected(s, false);
6521 this.$.selection.setItemSelected(this.selection, false);
6523 this.selectedItem = null;
6524 this.$.selection.clear();
6527 valueToSelection: function(value) {
6528 var item = (value === null || value === undefined) ?
6529 null : this.items[this.valueToIndex(value)];
6530 this.$.selection.select(item);
6533 updateSelectedItem: function() {
6534 this.selectedItem = this.selection;
6537 selectedItemChanged: function() {
6538 if (this.selectedItem) {
6539 var t = this.selectedItem.templateInstance;
6540 this.selectedModel = t ? t.model : undefined;
6542 this.selectedModel = null;
6544 this.selectedIndex = this.selectedItem ?
6545 parseInt(this.valueToIndex(this.selected)) : -1;
6548 valueToIndex: function(value) {
6549 // find an item with value == value and return it's index
6550 for (var i=0, items=this.items, c; (c=items[i]); i++) {
6551 if (this.valueForNode(c) == value) {
6555 // if no item found, the value itself is probably the index
6559 valueForNode: function(node) {
6560 return node[this.valueattr] || node.getAttribute(this.valueattr);
6563 // events fired from <core-selection> object
6564 selectionSelect: function(e, detail) {
6565 this.updateSelectedItem();
6567 this.applySelection(detail.item, detail.isSelected);
6571 applySelection: function(item, isSelected) {
6572 if (this.selectedClass) {
6573 item.classList.toggle(this.selectedClass, isSelected);
6575 if (this.selectedProperty) {
6576 item[this.selectedProperty] = isSelected;
6578 if (this.selectedAttribute && item.setAttribute) {
6580 item.setAttribute(this.selectedAttribute, '');
6582 item.removeAttribute(this.selectedAttribute);
6587 // event fired from host
6588 activateHandler: function(e) {
6590 var i = this.findDistributedTarget(e.target, this.items);
6592 var item = this.items[i];
6593 var s = this.valueForNode(item) || i;
6595 if (this.selected) {
6596 this.addRemoveSelected(s);
6598 this.selected = [s];
6603 this.asyncFire('core-activate', {item: item});
6608 addRemoveSelected: function(value) {
6609 var i = this.selected.indexOf(value);
6611 this.selected.splice(i, 1);
6613 this.selected.push(value);
6615 this.valueToSelection(value);
6618 findDistributedTarget: function(target, nodes) {
6619 // find first ancestor of target (including itself) that
6620 // is in nodes, if any
6621 while (target && target != this) {
6622 var i = Array.prototype.indexOf.call(nodes, target);
6626 target = target.parentNode;
6634 <style shim-shadowdom="">/*
6635 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6636 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6637 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6638 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6639 Code distributed by Google as part of the polymer project is also
6640 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
6643 html /deep/ core-menu {
6648 polyfill-next-selector { content: 'core-menu > core-item'; }
6649 html /deep/ core-menu::shadow ::content > core-item {
6654 <polymer-element name="core-menu" extends="core-selector" assetpath="../core-menu/">
6656 Polymer('core-menu',{});
6661 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6662 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6663 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6664 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6665 Code distributed by Google as part of the polymer project is also
6666 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
6670 `core-item` is a simple line-item object: a label and/or an icon that can also
6675 <core-item icon="settings" label="Settings"></core-item>
6677 To use as a link, put <a> element in the item.
6681 <core-item icon="settings" label="Settings">
6682 <a href="#settings" target="_self"></a>
6685 @group Polymer Core Elements
6692 <style shim-shadowdom="">/*
6693 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
6694 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6695 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6696 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6697 Code distributed by Google as part of the polymer project is also
6698 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
6701 html /deep/ core-item {
6705 white-space: nowrap;
6708 html /deep/ core-item.core-selected {
6712 html /deep/ core-item::shadow core-icon {
6713 margin: 0 16px 0 4px;
6716 html /deep/ core-item::shadow ::content > a {
6725 <polymer-element name="core-item" attributes="label icon src" horizontal="" center="" layout="" assetpath="../core-item/">
6728 <core-icon src="{{src}}" icon="{{icon}}" hidden?="{{!src && !icon}}"></core-icon>{{label}}<content></content>
6733 Polymer('core-item', {
6736 * The URL of an image for the icon.
6744 * Specifies the icon from the Polymer icon set.
6752 * Specifies the label for the menu item.
6769 <polymer-element name="core-doc-toc" attributes="data selected" assetpath="../core-doc-viewer/elements/">
6776 border-right: 1px solid silver;
6788 background-color: #eeeeee;
6792 <core-header-panel mode="waterfall">
6794 <!-- <core-toolbar theme="core-light-theme">
6795 <core-icon-button icon="menu"></core-icon-button>
6796 <span core-flex>Topics</span>
6797 <core-icon-button icon="search" on-tap="{{searchAction}}"></core-icon-button>
6800 <core-toolbar id="searchBar" style="background-color: #C2185B; position: absolute; top: 0; left: 0; right: 0; opacity: 0; display: none;" class="seamed" theme="core-dark-theme">
6801 <core-icon-button icon="search"></core-icon-button>
6802 <core-icon-button icon="close" on-tap="{{closeSearchAction}}"></core-icon-button>
6805 <core-menu selected="{{selected}}">
6806 <template repeat="{{data}}">
6807 <core-item><a href="#{{name}}">{{name}}</a></core-item>
6811 </core-header-panel>
6817 Polymer('core-doc-toc', {
6819 searchAction: function() {
6820 this.$.searchBar.style.opacity = 1;
6821 this.$.searchBar.style.display = '';
6824 closeSearchAction: function() {
6825 this.$.searchBar.style.opacity = 0;
6826 this.$.searchBar.style.display = 'none';
6838 Displays formatted source documentation scraped from input urls.
6840 Documentation can be encoded into html comments (<!-- ... -->) or using JsDoc notation (/** ... */).
6842 When using JsDoc notation, remember that the left-margin includes an asterisk and a single space.
6843 This is important for markdown constructs that count spaces. Code blocks for example, must be
6844 five spaces from the first asterisk.
6848 Markdown format is supported.
6852 Arbitrary links can be encoded using [standard markdown format](http://daringfireball.net/projects/markdown/syntax).
6853 [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) is also supported.
6855 Links to other topics can be made with hash-links [core-doc-viewer](#core-doc-viewer).
6861 Four space indents indicate code blocks.
6863 <code>blocks are syntax highlighted</code>
6867 javascript('is highlighted also');
6873 > Blockquote is supported for long text that needs to wrap with a common left side indent.
6874 > Blockquote is supported for long text that needs to wrap with a common left side indent.
6881 Use - or + for bullet points:
6888 | First Header | Second Header |
6889 | ------------- | ------------- |
6890 | Content Cell | Content Cell |
6891 | Content Cell | Content Cell |
6895 Arbitrary HTML is also supported
6897 <input><button>Button</button><hr/>
6899 @class core-doc-viewer
6903 <polymer-element name="core-doc-viewer" attributes="sources route url" assetpath="../core-doc-viewer/">
6917 <context-free-parser url="{{url}}" on-data-ready="{{parserDataReady}}"></context-free-parser>
6919 <template repeat="{{sources}}">
6920 <context-free-parser url="{{}}" on-data-ready="{{parserDataReady}}"></context-free-parser>
6923 <core-layout></core-layout>
6924 <core-doc-toc id="toc" data="{{classes}}" selected="{{selected}}"></core-doc-toc>
6925 <core-doc-page core-flex="" data="{{data}}"></core-doc-page>
6931 Polymer('core-doc-viewer', {
6933 * A single file to parse for docs
6941 * Class documentation extracted from the parser
6950 * Files to parse for docs
6952 * @attribute sources
6959 window.addEventListener('hashchange', this.parseLocationHash.bind(this));
6960 this.parseLocationHash();
6963 parseLocationHash: function() {
6964 this.route = window.location.hash.slice(1);
6967 routeChanged: function() {
6968 this.validateRoute();
6971 validateRoute: function() {
6973 this.classes.some(function(c) {
6974 if (c.name === this.route) {
6983 selectedChanged: function() {
6984 this.data = this.classes[this.selected];
6987 parserDataReady: function(event) {
6988 this.assimilateData(event.target.data);
6991 assimilateData: function(data) {
6992 this.classes = this.classes.concat(data.classes);
6993 this.classes.sort(function(a, b) {
6994 var na = a && a.name.toLowerCase(), nb = b && b.name.toLowerCase();
6995 return (na < nb) ? -1 : (na == nb) ? 0 : 1;
6997 if (!this.data && !this.route && this.classes.length) {
6998 this.data = this.classes[0];
7000 if (this.classes.length > 1) {
7001 this.$.toc.style.display = 'block';
7003 this.validateRoute();
7012 <div hidden>undefined</div>
7016 Implements the default landing page for Polymer components.
7018 `<core-component-page>` can render an information page for any component.
7019 Polymer components use this component in `index.html` to provide the standard landing page.
7021 `<core-component-page>` is _vulcanized_, which means it contains all it's dependencies baked in.
7022 Therefore, this component is intended to be used only by itself in a page.
7024 This *-dev package contains the raw source and the dependency manifest necessary
7025 to reconstruct `core-component-page\core-component-page.html` via vulcanize.
7027 `<core-component-page>` will set the page title automatically.
7029 @group Polymer Core Elements
7030 @element core-component-page
7034 <polymer-element name="core-component-page" attributes="moduleName sources" assetpath="../core-component-page-dev/">
7039 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
7040 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
7041 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7042 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7043 Code distributed by Google as part of the polymer project is also
7044 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
7048 font-family: Arial, sans-serif;
7053 display: inline-block;
7055 vertical-align: middle;
7058 .choiceB, .choiceC, .choiceD {
7061 /* font-size: 14px; */
7064 text-decoration: none;
7065 /* colors / effects */
7066 background-color: #4285F4;
7067 box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.1);
7068 box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.1);
7072 display: inline-block;
7073 padding: 4px 12px 5px 12px;
7078 background-color: #E91E63;
7083 <core-layout vertical=""></core-layout>
7085 <core-toolbar class="appbar">
7086 <span>{{moduleName}}</span>
7087 <a class="choiceC" target="_blank" href="../{{moduleName}}/demo.html">demo</a>
7090 <core-doc-viewer core-flex="" url="{{url}}" sources="{{sources}}"></core-doc-viewer>
7096 Polymer('core-component-page', {
7099 // TODO(sjmiles): needed this to force Object type for deserialization
7103 this.moduleName = this.moduleName || this.findModuleName();
7106 moduleNameChanged: function() {
7107 document.title = this.moduleName;
7108 this.url = !this.sources.length && this.moduleName ? this.moduleName + '.html' : '';
7111 findModuleName: function() {
7112 var path = location.pathname.split('/');
7113 var name = path.pop() || path.pop();
7114 if (name.indexOf('.html') >= 0) {