├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .mostrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── buildconfig.js ├── code-sample.js ├── demo ├── code-sample-theme.js ├── css │ └── demo.css ├── demo.js └── index.html ├── gulpfile.js ├── index.html ├── package-lock.json ├── package.json ├── src ├── code-sample.css └── code-sample.js ├── test ├── code-sample_test.html └── index.html ├── themes ├── default.js ├── github.js ├── kustom-dark.js ├── kustom-light.js ├── one-dark.js ├── one-light.js ├── solarized-dark.js └── solarized-light.js ├── vendor └── highlight │ ├── LICENSE │ └── highlight.pack.js └── wct.conf.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.css] 15 | insert_final_newline = false 16 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | vendor/ 4 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended", "google"], 3 | "parserOptions": { 4 | "ecmaVersion": 6, 5 | "sourceType": "module" 6 | }, 7 | "env": { 8 | "browser": true, 9 | "node": true 10 | }, 11 | "rules": { 12 | "brace-style": "off", 13 | "new-cap": ["error", { 14 | "capIsNewExceptions": [ 15 | "PolymerElement" 16 | ] 17 | }], 18 | "no-var": "off", 19 | "require-jsdoc": "off", 20 | "max-len": 0, 21 | "no-console": "off" 22 | }, 23 | "globals": { 24 | "Polymer": true, 25 | "hljs": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage*/ 2 | node_modules 3 | .tmp/ 4 | -------------------------------------------------------------------------------- /.mostrc: -------------------------------------------------------------------------------- 1 | { 2 | "css-api": { 3 | "file": "{{component}}.js", 4 | "docs": "README.md", 5 | "unformatted": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: required 3 | install: 4 | - npm install 5 | - npm install -g codecov 6 | before_script: 7 | - npm install -g polymer-cli@1.7.2 8 | env: 9 | global: 10 | - secure: 8k0dq8qt0SgD2jzb+QsQZuEv1dLp6GnTJnYwQ3g2BahPJwTrx3jn0OE1NR5r7z9gZM6lbODCQyAlOdMpjK7jFrAhI+E/3iLDp73agosqj499BPfNvZqIjflddp4XuUYi8Pid8gfzcl/5R4tG+HMXRWuvMeJ/76K9dA5kPJSjt/+Q7NTFNWnhAWrPo442BRWoZJ2oCV1DPCRk3Uo85Acc+dSIHrlmcQRV9w6xWbVhOkNzy+gE+Cw+898OhlHqQ90YFUvP8EW6pJPyL2eGMJA5W7FGXxmZqQT++mVgoKU0tjKOaOSXkoaH+J7JwvElFl4Jne7Oq6fQTcGhBkV3B2jluZBXZSysMZguxbQyI/VUDYft5Bl4toEdd8Ey65Em8jDThJN2UuGNl4cjSSZXt2UhhicmzgcJAjCy7E9dZ/aQJhMW5g69b6RpWoFKCjhT/9J0IACCQk7G91Upkkh3tON6sRBl+di/Mry05XVyYyAalKmE6GbWN3Wjsr2qelbr5Z9JWuGQMSbR/ge5hsliUGLcqeSZJ4iItCh/m6UvmuHMrKQyhRV8p7ZVdzQuFMkBmglR/ioVygnepQbIBuUzuoB4oswkjf1KhtafpW3HYQ1xtrFVbkjNN+ig4ezmSaHLCflP6SsyaUlpKMmTXkwCmhQxfmRQ/+AfLsKyfIPmbRCBcNw= 11 | - secure: A6VSRhqOE1BadqdEyf6hT0uNdoFEfvRVQ7SX/qCp7/RukUtm3EtKh9hFim9P/5jnCGS9zU6GMwyZWSTJraTJVd+TRJT1v+Aiw9BeVbTLnL8kS3P2rL2aInhpoh9Lsm5V7mrvlKJHXhch1E/QSqdn6EEcN9Jqnrq0PICkU1H6xUZ0noBy6BADWn8Hy7k5BYDamThAM+k4877KnOh75vuhKQpER9CYNzFyzXOausZ7D9k+KoQRWKvW3PBeAxkgU2Nd+I8gol+5ZY3huN957vAd9Ue05NlnhdQZJbgJkn5aTm2XZCjEtkKVQ+DLyQCd6K/rzJUxZLpfsCRrf3QcmxAGb0P2ZxzznJACeKv1TfrE071ik9iUWuYOuXDdr6ZRXM0fI3uMAhTePi/QKQrfeK9TfYxUuWeW6QmkERNPiDMme4ap16vqRrFHZ+65GNL0mRpilJ2pztQyXMufZrh0FhcW/aypgLJgvB1lL/PdEwQbyOZobcz5YJTHc6nX1dB+t9lGh1NOqybf32PwXkgQ0+o3tnjhsSsAQ8HeoSmZ20Z8cLXV8A9wilYkIYBzIrZS4GwLCuC6uBnu+ov4cTy0JVI9/Ezd6/tyvYVYLCtPsWqnL1LJnqx5mtXBDPBWYs092qdV7CgcQ3zoVUzft42GYDSUKzEGgXvhb3JTUotlyboZKKo= 12 | node_js: 13 | - "8" 14 | addons: 15 | chrome: stable 16 | script: 17 | - xvfb-run npm run test:sauce 18 | - codecov 19 | dist: trusty 20 | 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v1.0.0 4 | 5 | - Migrated to Polymer 3 and npm. Thanks to [@sergicontre](https://github.com/sergicontre) 6 | 7 | ## v0.4.2 8 | 9 | - Fix: entitized chars (< and >) not replaced. 10 | 11 | ## v0.4.0 12 | 13 | - Copy to clipboard functionallity added. Thanks to [@lpellegr](https://github.com/lpellegr) 14 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kus Cámara 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # <code-sample> 2 | [![Build Status](https://img.shields.io/travis/kcmr/code-sample/master.svg?style=flat-square)](https://travis-ci.org/kcmr/code-sample) 3 | [![codecov](https://codecov.io/gh/kcmr/code-sample/branch/master/graph/badge.svg)](https://codecov.io/gh/kcmr/code-sample) 4 | [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg?style=flat-square)](https://www.webcomponents.org/element/@kuscamara/code-sample) 5 | [![npm version](https://badge.fury.io/js/%40kuscamara%2Fcode-sample.svg)](https://badge.fury.io/js/%40kuscamara%2Fcode-sample) 6 | ![Polymer 3](https://img.shields.io/badge/Polymer-3-green.svg) 7 | 8 | > A wrapper element for [highlight.js](https://highlightjs.org/) 9 | 10 | A themeable sample code snippet that uses [highlight.js](https://highlightjs.org/) for syntax highlighting. 11 | Forget to worry about spaces, indentation, HTML entities, etc. 12 | 13 | ```html 14 | 15 | 20 | 21 | ``` 22 | 23 | ## Installation 24 | 25 | 1. Install the component using Npm: 26 | ```bash 27 | $ npm i -S @kuscamara/code-sample 28 | ``` 29 | 2. Import Web Components loader (optional): 30 | ```html 31 | 32 | ``` 33 | 3. Import the component: 34 | ```html 35 | 36 | ``` 37 | 38 | ## Usage 39 | 40 | The code to highlight must be provided inside a `