├── babel.config.js ├── demo ├── themes.png ├── favicon.ico ├── screenshot2.png ├── window-controls.svg ├── index.html ├── js │ ├── app.878e9d7a.js │ └── app.878e9d7a.js.map └── css │ └── app.67e415ed.css ├── public ├── themes.png ├── favicon.ico ├── screenshot2.png ├── window-controls.svg └── index.html ├── src ├── registerDirective.js ├── main.js ├── wrapper.js ├── CodeHighlight.vue └── App.vue ├── .editorconfig ├── .gitignore ├── rollup.config.js ├── themes ├── window.css ├── prism-tomorrow.css ├── prism-okaidia.css ├── prism-funky.css ├── prism-dark.css ├── prism.css ├── prism-solarizedlight.css ├── duotone-sea.css ├── prism-twilight.css └── prism-coy.css ├── LICENSE ├── .eslintrc.js ├── package.json ├── README.md └── dist ├── vue-code-highlight.esm.js ├── vue-code-highlight.min.js └── vue-code-highlight.umd.js /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } -------------------------------------------------------------------------------- /demo/themes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elisiondesign/vue-code-highlight/HEAD/demo/themes.png -------------------------------------------------------------------------------- /demo/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elisiondesign/vue-code-highlight/HEAD/demo/favicon.ico -------------------------------------------------------------------------------- /public/themes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elisiondesign/vue-code-highlight/HEAD/public/themes.png -------------------------------------------------------------------------------- /demo/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elisiondesign/vue-code-highlight/HEAD/demo/screenshot2.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elisiondesign/vue-code-highlight/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elisiondesign/vue-code-highlight/HEAD/public/screenshot2.png -------------------------------------------------------------------------------- /src/registerDirective.js: -------------------------------------------------------------------------------- 1 | import Prism from 'prism-es6'; 2 | 3 | export default function (el) { 4 | Prism.highlightAllUnder(el); 5 | } 6 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | 4 | Vue.config.productionTip = false; 5 | 6 | new Vue({ 7 | render: h => h(App), 8 | }).$mount('#app'); 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | 4 | # local env files 5 | .env.local 6 | .env.*.local 7 | 8 | # Log files 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | 13 | # Editor directories and files 14 | .idea 15 | .vscode 16 | *.suo 17 | *.ntvs* 18 | *.njsproj 19 | *.sln 20 | *.sw* 21 | -------------------------------------------------------------------------------- /demo/window-controls.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /public/window-controls.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import vue from 'rollup-plugin-vue'; // Handle .vue SFC files 2 | import buble from 'rollup-plugin-buble'; 3 | import resolve from 'rollup-plugin-node-resolve'; 4 | // Transpile/polyfill with reasonable browser support 5 | export default { 6 | input: 'src/wrapper.js', // Path relative to package.json 7 | output: { 8 | name: 'vueCodeHighlight', 9 | exports: 'named', 10 | }, 11 | plugins: [ 12 | vue({ 13 | css: true, // Dynamically inject css as a 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 elision.design 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 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // https://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parserOptions: { 6 | parser: 'babel-eslint' 7 | }, 8 | env: { 9 | browser: true, 10 | }, 11 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 12 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 13 | extends: ['plugin:vue/essential', 'airbnb-base'], 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'vue' 17 | ], 18 | // check if imports actually resolve 19 | settings: { 20 | 'import/resolver': { 21 | webpack: { 22 | config: 'build/webpack.base.conf.js' 23 | } 24 | } 25 | }, 26 | // add your custom rules here 27 | rules: { 28 | // don't require .vue extension when importing 29 | 'import/extensions': ['error', 'always', { 30 | js: 'never', 31 | vue: 'never' 32 | }], 33 | // disallow reassignment of function parameters 34 | // disallow parameter object manipulation except for specific exclusions 35 | 'no-param-reassign': ['error', { 36 | props: true, 37 | ignorePropertyModificationsFor: [ 38 | 'state', // for vuex state 39 | 'acc', // for reduce accumulators 40 | 'e' // for e.returnvalue 41 | ] 42 | }], 43 | // allow optionalDependencies 44 | 'import/no-extraneous-dependencies': ['error', { 45 | optionalDependencies: ['test/unit/index.js'] 46 | }], 47 | // allow debugger during development 48 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 49 | // Warnings 50 | 'comma-dangle': 1, 51 | 'arrow-parens': [0, "as-needed"], 52 | 'no-unused-vars': 1, 53 | 'quotes': 1, 54 | 'padded-blocks': 1, 55 | 'spaced-comment': 1, 56 | "linebreak-style": 0, 57 | "no-mixed-operators": 0, 58 | "max-len": 0, 59 | 'no-param-reassign': 0, 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-code-highlight", 3 | "version": "0.7.8", 4 | "author": "Jan Bílek", 5 | "email": "honza@elision.design", 6 | "url": "https://elision.design/", 7 | "private": false, 8 | "license": "MIT", 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/elisiondesign/vue-code-highlight" 12 | }, 13 | "scripts": { 14 | "start": "vue-cli-service serve", 15 | "build": "vue-cli-service build --dest demo && npm run build-bundle", 16 | "build-bundle": "npm run build:umd & npm run build:es & npm run build:unpkg", 17 | "build:umd": "rollup --config rollup.config.js --format umd --file dist/vue-code-highlight.umd.js", 18 | "build:es": "rollup --config rollup.config.js --format es --file dist/vue-code-highlight.esm.js", 19 | "build:unpkg": "rollup --config rollup.config.js --format iife --file dist/vue-code-highlight.min.js", 20 | "lint": "vue-cli-service lint", 21 | "deploy": "git subtree push --prefix demo origin gh-pages" 22 | }, 23 | "dependencies": { 24 | "prism-es6": "^1.2.0", 25 | "vue": "^2.5.16" 26 | }, 27 | "devDependencies": { 28 | "@vue/cli-plugin-babel": "^3.0.0-rc.5", 29 | "@vue/cli-plugin-eslint": "^3.0.0-rc.5", 30 | "@vue/cli-service": "^3.0.0-rc.5", 31 | "eslint-config-airbnb-base": "^13.0.0", 32 | "eslint-plugin-import": "^2.13.0", 33 | "rollup": "^0.57.1", 34 | "rollup-plugin-buble": "^0.19.2", 35 | "rollup-plugin-node-resolve": "^3.3.0", 36 | "rollup-plugin-vue": "^3.0.0", 37 | "vue-template-compiler": "^2.5.16" 38 | }, 39 | "main": "dist/vue-code-highlight.umd.js", 40 | "module": "dist/vue-code-highlight.esm.js", 41 | "unpkg": "dist/vue-code-highlight.min.js", 42 | "browser": { 43 | "./sfc": "src/CodeHighlight.vue" 44 | }, 45 | "keywords": [ 46 | "Vue", 47 | "Code highlight", 48 | "Prism" 49 | ], 50 | "eslintConfig": { 51 | "root": true, 52 | "env": { 53 | "node": true 54 | }, 55 | "extends": [ 56 | "plugin:vue/essential", 57 | "eslint:recommended" 58 | ], 59 | "rules": {}, 60 | "parserOptions": { 61 | "parser": "babel-eslint" 62 | } 63 | }, 64 | "postcss": { 65 | "plugins": { 66 | "autoprefixer": {} 67 | } 68 | }, 69 | "browserslist": [ 70 | "> 1%", 71 | "last 2 versions", 72 | "not ie <= 8" 73 | ] 74 | } 75 | -------------------------------------------------------------------------------- /themes/prism-tomorrow.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML 3 | * Based on https://github.com/chriskempson/tomorrow-theme 4 | * @author Rose Pritchard 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: #ccc; 10 | background: none; 11 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 12 | text-align: left; 13 | white-space: pre; 14 | word-spacing: normal; 15 | word-break: normal; 16 | word-wrap: normal; 17 | line-height: 1.5; 18 | 19 | -moz-tab-size: 4; 20 | -o-tab-size: 4; 21 | tab-size: 4; 22 | 23 | -webkit-hyphens: none; 24 | -moz-hyphens: none; 25 | -ms-hyphens: none; 26 | hyphens: none; 27 | 28 | } 29 | 30 | /* Code blocks */ 31 | pre[class*="language-"] { 32 | padding: 1em; 33 | margin: .5em 0; 34 | overflow: auto; 35 | } 36 | 37 | :not(pre) > code[class*="language-"], 38 | pre[class*="language-"] { 39 | background: #2d2d2d; 40 | } 41 | 42 | /* Inline code */ 43 | :not(pre) > code[class*="language-"] { 44 | padding: .1em; 45 | border-radius: .3em; 46 | white-space: normal; 47 | } 48 | 49 | .token.comment, 50 | .token.block-comment, 51 | .token.prolog, 52 | .token.doctype, 53 | .token.cdata { 54 | color: #999; 55 | } 56 | 57 | .token.punctuation { 58 | color: #ccc; 59 | } 60 | 61 | .token.tag, 62 | .token.attr-name, 63 | .token.namespace, 64 | .token.deleted { 65 | color: #e2777a; 66 | } 67 | 68 | .token.function-name { 69 | color: #6196cc; 70 | } 71 | 72 | .token.boolean, 73 | .token.number, 74 | .token.function { 75 | color: #f08d49; 76 | } 77 | 78 | .token.property, 79 | .token.class-name, 80 | .token.constant, 81 | .token.symbol { 82 | color: #f8c555; 83 | } 84 | 85 | .token.selector, 86 | .token.important, 87 | .token.atrule, 88 | .token.keyword, 89 | .token.builtin { 90 | color: #cc99cd; 91 | } 92 | 93 | .token.string, 94 | .token.char, 95 | .token.attr-value, 96 | .token.regex, 97 | .token.variable { 98 | color: #7ec699; 99 | } 100 | 101 | .token.operator, 102 | .token.entity, 103 | .token.url { 104 | color: #67cdcc; 105 | } 106 | 107 | .token.important, 108 | .token.bold { 109 | font-weight: bold; 110 | } 111 | .token.italic { 112 | font-style: italic; 113 | } 114 | 115 | .token.entity { 116 | cursor: help; 117 | } 118 | 119 | .token.inserted { 120 | color: green; 121 | } 122 | -------------------------------------------------------------------------------- /themes/prism-okaidia.css: -------------------------------------------------------------------------------- 1 | /** 2 | * okaidia theme for JavaScript, CSS and HTML 3 | * Loosely based on Monokai textmate theme by http://www.monokai.nl/ 4 | * @author ocodia 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: #f8f8f2; 10 | background: none; 11 | text-shadow: 0 1px rgba(0, 0, 0, 0.3); 12 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 13 | text-align: left; 14 | white-space: pre; 15 | word-spacing: normal; 16 | word-break: normal; 17 | word-wrap: normal; 18 | line-height: 1.5; 19 | 20 | -moz-tab-size: 4; 21 | -o-tab-size: 4; 22 | tab-size: 4; 23 | 24 | -webkit-hyphens: none; 25 | -moz-hyphens: none; 26 | -ms-hyphens: none; 27 | hyphens: none; 28 | } 29 | 30 | /* Code blocks */ 31 | pre[class*="language-"] { 32 | padding: 1em; 33 | margin: .5em 0; 34 | overflow: auto; 35 | border-radius: 0.3em; 36 | } 37 | 38 | :not(pre) > code[class*="language-"], 39 | pre[class*="language-"] { 40 | background: #272822; 41 | } 42 | 43 | /* Inline code */ 44 | :not(pre) > code[class*="language-"] { 45 | padding: .1em; 46 | border-radius: .3em; 47 | white-space: normal; 48 | } 49 | 50 | .token.comment, 51 | .token.prolog, 52 | .token.doctype, 53 | .token.cdata { 54 | color: slategray; 55 | } 56 | 57 | .token.punctuation { 58 | color: #f8f8f2; 59 | } 60 | 61 | .namespace { 62 | opacity: .7; 63 | } 64 | 65 | .token.property, 66 | .token.tag, 67 | .token.constant, 68 | .token.symbol, 69 | .token.deleted { 70 | color: #f92672; 71 | } 72 | 73 | .token.boolean, 74 | .token.number { 75 | color: #ae81ff; 76 | } 77 | 78 | .token.selector, 79 | .token.attr-name, 80 | .token.string, 81 | .token.char, 82 | .token.builtin, 83 | .token.inserted { 84 | color: #a6e22e; 85 | } 86 | 87 | .token.operator, 88 | .token.entity, 89 | .token.url, 90 | .language-css .token.string, 91 | .style .token.string, 92 | .token.variable { 93 | color: #f8f8f2; 94 | } 95 | 96 | .token.atrule, 97 | .token.attr-value, 98 | .token.function, 99 | .token.class-name { 100 | color: #e6db74; 101 | } 102 | 103 | .token.keyword { 104 | color: #66d9ef; 105 | } 106 | 107 | .token.regex, 108 | .token.important { 109 | color: #fd971f; 110 | } 111 | 112 | .token.important, 113 | .token.bold { 114 | font-weight: bold; 115 | } 116 | .token.italic { 117 | font-style: italic; 118 | } 119 | 120 | .token.entity { 121 | cursor: help; 122 | } 123 | -------------------------------------------------------------------------------- /themes/prism-funky.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js Funky theme 3 | * Based on “Polyfilling the gaps” talk slides http://lea.verou.me/polyfilling-the-gaps/ 4 | * @author Lea Verou 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 10 | text-align: left; 11 | white-space: pre; 12 | word-spacing: normal; 13 | word-break: normal; 14 | word-wrap: normal; 15 | line-height: 1.5; 16 | 17 | -moz-tab-size: 4; 18 | -o-tab-size: 4; 19 | tab-size: 4; 20 | 21 | -webkit-hyphens: none; 22 | -moz-hyphens: none; 23 | -ms-hyphens: none; 24 | hyphens: none; 25 | } 26 | 27 | /* Code blocks */ 28 | pre[class*="language-"] { 29 | padding: .4em .8em; 30 | margin: .5em 0; 31 | overflow: auto; 32 | background: url('data:image/svg+xml;charset=utf-8,%0D%0A%0D%0A%0D%0A<%2Fsvg>'); 33 | background-size: 1em 1em; 34 | } 35 | 36 | code[class*="language-"] { 37 | background: black; 38 | color: white; 39 | box-shadow: -.3em 0 0 .3em black, .3em 0 0 .3em black; 40 | } 41 | 42 | /* Inline code */ 43 | :not(pre) > code[class*="language-"] { 44 | padding: .2em; 45 | border-radius: .3em; 46 | box-shadow: none; 47 | white-space: normal; 48 | } 49 | 50 | .token.comment, 51 | .token.prolog, 52 | .token.doctype, 53 | .token.cdata { 54 | color: #aaa; 55 | } 56 | 57 | .token.punctuation { 58 | color: #999; 59 | } 60 | 61 | .namespace { 62 | opacity: .7; 63 | } 64 | 65 | .token.property, 66 | .token.tag, 67 | .token.boolean, 68 | .token.number, 69 | .token.constant, 70 | .token.symbol { 71 | color: #0cf; 72 | } 73 | 74 | .token.selector, 75 | .token.attr-name, 76 | .token.string, 77 | .token.char, 78 | .token.builtin { 79 | color: yellow; 80 | } 81 | 82 | .token.operator, 83 | .token.entity, 84 | .token.url, 85 | .language-css .token.string, 86 | .toke.variable, 87 | .token.inserted { 88 | color: yellowgreen; 89 | } 90 | 91 | .token.atrule, 92 | .token.attr-value, 93 | .token.keyword { 94 | color: deeppink; 95 | } 96 | 97 | .token.regex, 98 | .token.important { 99 | color: orange; 100 | } 101 | 102 | .token.important, 103 | .token.bold { 104 | font-weight: bold; 105 | } 106 | .token.italic { 107 | font-style: italic; 108 | } 109 | 110 | .token.entity { 111 | cursor: help; 112 | } 113 | 114 | .token.deleted { 115 | color: red; 116 | } 117 | -------------------------------------------------------------------------------- /themes/prism-dark.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js Dark theme for JavaScript, CSS and HTML 3 | * Based on the slides of the talk “/Reg(exp){2}lained/” 4 | * @author Lea Verou 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: white; 10 | background: none; 11 | text-shadow: 0 -.1em .2em black; 12 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 13 | text-align: left; 14 | white-space: pre; 15 | word-spacing: normal; 16 | word-break: normal; 17 | word-wrap: normal; 18 | line-height: 1.5; 19 | 20 | -moz-tab-size: 4; 21 | -o-tab-size: 4; 22 | tab-size: 4; 23 | 24 | -webkit-hyphens: none; 25 | -moz-hyphens: none; 26 | -ms-hyphens: none; 27 | hyphens: none; 28 | } 29 | 30 | @media print { 31 | code[class*="language-"], 32 | pre[class*="language-"] { 33 | text-shadow: none; 34 | } 35 | } 36 | 37 | pre[class*="language-"], 38 | :not(pre) > code[class*="language-"] { 39 | background: hsl(30, 20%, 25%); 40 | } 41 | 42 | /* Code blocks */ 43 | pre[class*="language-"] { 44 | padding: 1em; 45 | margin: .5em 0; 46 | overflow: auto; 47 | border: .3em solid hsl(30, 20%, 40%); 48 | border-radius: .5em; 49 | box-shadow: 1px 1px .5em black inset; 50 | } 51 | 52 | /* Inline code */ 53 | :not(pre) > code[class*="language-"] { 54 | padding: .15em .2em .05em; 55 | border-radius: .3em; 56 | border: .13em solid hsl(30, 20%, 40%); 57 | box-shadow: 1px 1px .3em -.1em black inset; 58 | white-space: normal; 59 | } 60 | 61 | .token.comment, 62 | .token.prolog, 63 | .token.doctype, 64 | .token.cdata { 65 | color: hsl(30, 20%, 50%); 66 | } 67 | 68 | .token.punctuation { 69 | opacity: .7; 70 | } 71 | 72 | .namespace { 73 | opacity: .7; 74 | } 75 | 76 | .token.property, 77 | .token.tag, 78 | .token.boolean, 79 | .token.number, 80 | .token.constant, 81 | .token.symbol { 82 | color: hsl(350, 40%, 70%); 83 | } 84 | 85 | .token.selector, 86 | .token.attr-name, 87 | .token.string, 88 | .token.char, 89 | .token.builtin, 90 | .token.inserted { 91 | color: hsl(75, 70%, 60%); 92 | } 93 | 94 | .token.operator, 95 | .token.entity, 96 | .token.url, 97 | .language-css .token.string, 98 | .style .token.string, 99 | .token.variable { 100 | color: hsl(40, 90%, 60%); 101 | } 102 | 103 | .token.atrule, 104 | .token.attr-value, 105 | .token.keyword { 106 | color: hsl(350, 40%, 70%); 107 | } 108 | 109 | .token.regex, 110 | .token.important { 111 | color: #e90; 112 | } 113 | 114 | .token.important, 115 | .token.bold { 116 | font-weight: bold; 117 | } 118 | .token.italic { 119 | font-style: italic; 120 | } 121 | 122 | .token.entity { 123 | cursor: help; 124 | } 125 | 126 | .token.deleted { 127 | color: red; 128 | } 129 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-code-highlight 2 | 3 | > Beautiful code syntax highlighting as Vue.js component. 4 | 5 | ## Examples 6 | https://codesandbox.io/s/vue-code-highlight-example-63h5m 7 | ![screenshot](/public/screenshot2.png) 8 | 9 | ## Usage 10 | 11 | ``` 12 | npm install vue-code-highlight --save 13 | ``` 14 | 15 | Now, you can use this module in two diferrent ways, as a component or as a directive. 16 | 17 | ### Component 18 | In any component: 19 | 20 | ```js 21 | // You have to extract the component from the module 22 | import { component as VueCodeHighlight } from 'vue-code-highlight'; 23 | 24 | components:{ 25 | VueCodeHighlight, 26 | ... 27 | } 28 | ``` 29 | 30 | ```html 31 | 32 |
33 |  //Paste your code here
34 |  
35 |
36 | ``` 37 | **Props** 38 | |Prop |Description 39 | |:--------------|:------------------------------------------| 40 | | **language** | Pass language name you want to highlight. Options: https://prismjs.com/#supported-languages | 41 | 42 | Your content will be highlighted dynamically when it updates. 43 | 44 | The `
` tag is required to preserve newline characters (They're stripped by default in Vue).
45 | 
46 | Window styles are already present in a component mode, but you will need to select and include a theme to properly highlight your code. (See the themes section.)
47 | 
48 | ### Directive
49 | In your main file:
50 | ```js
51 | import VueCodeHighlight from 'vue-code-highlight';
52 | 
53 | Vue.use(VueCodeHighlight) //registers the v-highlight directive
54 | 
55 | ```
56 | And then in any Vue component:
57 | 
58 | ```html
59 | 
60 | ... 61 |
62 | ``` 63 | All markup under the div element having the following structure will be syntax highlighted. 64 | 65 | ```html 66 |
67 |   
68 |     //your code goes here
69 |   
70 | 
71 | ``` 72 | 73 | To give the highlighter a window look in a directive mode, also don't forget to include the `./node_modules/vue-code-highlight/themes/window.css` file somewhere in your app. 74 | 75 | ## Themes 76 | In order to visually higlight your code, you need to select a theme from `./node_modules/vue-code-highlight/themes/` and import it somewhere into your component/application. These are just regular prism themes, so feel free to improvise. 77 | 78 | ![themes](/public/themes.png) 79 | 80 | ## Other languages 81 | 82 | Any of the [supported languages](https://prismjs.com/index.html#supported-languages) in Prism may be used. To enable support 83 | for them, you must import them explicitly as well as Prism's markup templating. 84 | 85 | For example, to include PHP highlighting in your application: 86 | 87 | ```jsx 88 | import 'prism-es6/components/prism-markup-templating'; 89 | import 'prism-es6/components/prism-php'; 90 | ``` 91 | -------------------------------------------------------------------------------- /demo/js/app.878e9d7a.js: -------------------------------------------------------------------------------- 1 | (function(e){function t(t){for(var r,i,u=t[0],a=t[1],c=t[2],f=0,d=[];f {\n let [length, result] = [word.length, true];\n\n for (let i = 0; i < length / 2; i++) {\n if (word[i] !== word[length - 1 - i]) result = false;\n }\n return result;\n }\n\n module.exports = isPalindrome;\n")])},l=[],i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"codeBlock"},[n("pre",{class:e.languageClass},[n("code",[e._t("default")],2)])])},u=[],a=(n("pIFo"),n("eLaB")),c={name:"code-highlight",props:{language:{type:String,default:"javascript"}},computed:{languageClass:function(){return"language-".concat(this.language)}},mounted:function(){a["a"].highlightAllUnder(this.$refs.codeBlock)},beforeUpdate:function(){var e=this.$slots.default[0].text.replace(/^[\r\n\s]*|[\r\n\s]*$/g,"");this.$el.querySelector("code").textContent=e,a["a"].highlightAllUnder(this.$refs.codeBlock)}},s=c,f=n("KHd+"),d=Object(f["a"])(s,i,u,!1,null,null,null),p=d.exports,h={name:"app",components:{CodeHighlight:p},data:function(){return{dynamicCode:"
Type here to see me change below
"}}},g=h,v=(n("A0++"),Object(f["a"])(g,o,l,!1,null,null,null)),b=v.exports;r["a"].config.productionTip=!1,new r["a"]({render:function(e){return e(b)}}).$mount("#app")}}); 2 | //# sourceMappingURL=app.878e9d7a.js.map -------------------------------------------------------------------------------- /themes/prism.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js default theme for JavaScript, CSS and HTML 3 | * Based on dabblet (http://dabblet.com) 4 | * @author Lea Verou 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: black; 10 | background: none; 11 | text-shadow: 0 1px white; 12 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 13 | text-align: left; 14 | white-space: pre; 15 | word-spacing: normal; 16 | word-break: normal; 17 | word-wrap: normal; 18 | line-height: 1.5; 19 | 20 | -moz-tab-size: 4; 21 | -o-tab-size: 4; 22 | tab-size: 4; 23 | 24 | -webkit-hyphens: none; 25 | -moz-hyphens: none; 26 | -ms-hyphens: none; 27 | hyphens: none; 28 | } 29 | 30 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, 31 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 32 | text-shadow: none; 33 | background: #b3d4fc; 34 | } 35 | 36 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection, 37 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 38 | text-shadow: none; 39 | background: #b3d4fc; 40 | } 41 | 42 | @media print { 43 | code[class*="language-"], 44 | pre[class*="language-"] { 45 | text-shadow: none; 46 | } 47 | } 48 | 49 | /* Code blocks */ 50 | pre[class*="language-"] { 51 | padding: 1em; 52 | margin: .5em 0; 53 | overflow: auto; 54 | } 55 | 56 | :not(pre) > code[class*="language-"], 57 | pre[class*="language-"] { 58 | background: #f5f2f0; 59 | } 60 | 61 | /* Inline code */ 62 | :not(pre) > code[class*="language-"] { 63 | padding: .1em; 64 | border-radius: .3em; 65 | white-space: normal; 66 | } 67 | 68 | .token.comment, 69 | .token.prolog, 70 | .token.doctype, 71 | .token.cdata { 72 | color: slategray; 73 | } 74 | 75 | .token.punctuation { 76 | color: #999; 77 | } 78 | 79 | .namespace { 80 | opacity: .7; 81 | } 82 | 83 | .token.property, 84 | .token.tag, 85 | .token.boolean, 86 | .token.number, 87 | .token.constant, 88 | .token.symbol, 89 | .token.deleted { 90 | color: #905; 91 | } 92 | 93 | .token.selector, 94 | .token.attr-name, 95 | .token.string, 96 | .token.char, 97 | .token.builtin, 98 | .token.inserted { 99 | color: #690; 100 | } 101 | 102 | .token.operator, 103 | .token.entity, 104 | .token.url, 105 | .language-css .token.string, 106 | .style .token.string { 107 | color: #9a6e3a; 108 | background: hsla(0, 0%, 100%, .5); 109 | } 110 | 111 | .token.atrule, 112 | .token.attr-value, 113 | .token.keyword { 114 | color: #07a; 115 | } 116 | 117 | .token.function, 118 | .token.class-name { 119 | color: #DD4A68; 120 | } 121 | 122 | .token.regex, 123 | .token.important, 124 | .token.variable { 125 | color: #e90; 126 | } 127 | 128 | .token.important, 129 | .token.bold { 130 | font-weight: bold; 131 | } 132 | .token.italic { 133 | font-style: italic; 134 | } 135 | 136 | .token.entity { 137 | cursor: help; 138 | } 139 | -------------------------------------------------------------------------------- /demo/css/app.67e415ed.css: -------------------------------------------------------------------------------- 1 | code[class*=language-],pre[class*=language-]{-moz-tab-size:4;-ms-hyphens:none;-o-tab-size:4;-webkit-hyphens:none;background:#1d262f;color:#57718e;direction:ltr;font-family:Hack,Consolas,Menlo,Monaco,Andale Mono WT,Andale Mono,Lucida Console,Lucida Sans Typewriter,DejaVu Sans Mono,Bitstream Vera Sans Mono,Liberation Mono,Nimbus Mono L,Courier New,Courier,monospace;font-size:14px;hyphens:none;line-height:1.375;tab-size:4;text-align:left;white-space:pre;word-break:normal;word-spacing:normal}code[class*=language-]::-moz-selection,code[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection{background:#004a9e;text-shadow:none}code[class*=language-]::selection,code[class*=language-] ::selection,pre[class*=language-]::selection,pre[class*=language-] ::selection{background:#004a9e;text-shadow:none}pre[class*=language-]{margin:.5em 0;overflow:auto;padding:1em}:not(pre)>code[class*=language-]{border-radius:.3em;padding:.1em}.token.cdata,.token.comment,.token.doctype,.token.prolog,.token.punctuation{color:#4a5f78}.token.namespace{opacity:.7}.token.number,.token.operator,.token.tag{color:#0aa370}.token.function,.token.property{color:#57718e}.token.atrule-id,.token.selector,.token.tag-id{color:#ebf4ff}.token.attr-name,code.language-javascript{color:#7eb6f6}.language-css .token.string,.language-scss .token.string,.style .token.string,.token.atrule,.token.attr-value,.token.boolean,.token.control,.token.directive,.token.entity,.token.keyword,.token.placeholder,.token.regex,.token.statement,.token.string,.token.unit,.token.url,.token.variable,code.language-css,code.language-scss{color:#47ebb4}.token.deleted{text-decoration:line-through}.token.inserted{border-bottom:1px dotted #ebf4ff;text-decoration:none}.token.italic{font-style:italic}.token.bold,.token.important{font-weight:700}.token.important{color:#7eb6f6}.token.entity{cursor:help}pre>code.highlight{outline:.4em solid #34659d;outline-offset:.4em}.line-numbers .line-numbers-rows{border-right-color:#1f2932}.line-numbers-rows>span:before{color:#2c3847}.line-highlight{background:rgba(10,163,112,.2);background:-webkit-gradient(linear,left top,right top,color-stop(70%,rgba(10,163,112,.2)),to(rgba(10,163,112,0)));background:linear-gradient(90deg,rgba(10,163,112,.2) 70%,rgba(10,163,112,0))}div pre[class*=language-]{-webkit-box-shadow:5px 5px 15px 0 rgba(50,50,50,.75);background-image:url('data:image/svg+xml;utf8, ');background-position:16px 16px;background-repeat:no-repeat;border-radius:6px;box-shadow:5px 5px 15px 0 rgba(50,50,50,.75);display:inline-block;padding-right:10em;padding-top:3rem}body{-ms-flex-align:center;-ms-flex-pack:center;-webkit-box-align:center;-webkit-box-pack:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;height:100vh;justify-content:center;margin:0} -------------------------------------------------------------------------------- /themes/prism-solarizedlight.css: -------------------------------------------------------------------------------- 1 | /* 2 | Solarized Color Schemes originally by Ethan Schoonover 3 | http://ethanschoonover.com/solarized 4 | 5 | Ported for PrismJS by Hector Matos 6 | Website: https://krakendev.io 7 | Twitter Handle: https://twitter.com/allonsykraken) 8 | */ 9 | 10 | /* 11 | SOLARIZED HEX 12 | --------- ------- 13 | base03 #002b36 14 | base02 #073642 15 | base01 #586e75 16 | base00 #657b83 17 | base0 #839496 18 | base1 #93a1a1 19 | base2 #eee8d5 20 | base3 #fdf6e3 21 | yellow #b58900 22 | orange #cb4b16 23 | red #dc322f 24 | magenta #d33682 25 | violet #6c71c4 26 | blue #268bd2 27 | cyan #2aa198 28 | green #859900 29 | */ 30 | 31 | code[class*="language-"], 32 | pre[class*="language-"] { 33 | color: #657b83; /* base00 */ 34 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 35 | text-align: left; 36 | white-space: pre; 37 | word-spacing: normal; 38 | word-break: normal; 39 | word-wrap: normal; 40 | 41 | line-height: 1.5; 42 | 43 | -moz-tab-size: 4; 44 | -o-tab-size: 4; 45 | tab-size: 4; 46 | 47 | -webkit-hyphens: none; 48 | -moz-hyphens: none; 49 | -ms-hyphens: none; 50 | hyphens: none; 51 | } 52 | 53 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, 54 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 55 | background: #073642; /* base02 */ 56 | } 57 | 58 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection, 59 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 60 | background: #073642; /* base02 */ 61 | } 62 | 63 | /* Code blocks */ 64 | pre[class*="language-"] { 65 | padding: 1em; 66 | margin: .5em 0; 67 | overflow: auto; 68 | border-radius: 0.3em; 69 | } 70 | 71 | :not(pre) > code[class*="language-"], 72 | pre[class*="language-"] { 73 | background-color: #fdf6e3; /* base3 */ 74 | } 75 | 76 | /* Inline code */ 77 | :not(pre) > code[class*="language-"] { 78 | padding: .1em; 79 | border-radius: .3em; 80 | } 81 | 82 | .token.comment, 83 | .token.prolog, 84 | .token.doctype, 85 | .token.cdata { 86 | color: #93a1a1; /* base1 */ 87 | } 88 | 89 | .token.punctuation { 90 | color: #586e75; /* base01 */ 91 | } 92 | 93 | .namespace { 94 | opacity: .7; 95 | } 96 | 97 | .token.property, 98 | .token.tag, 99 | .token.boolean, 100 | .token.number, 101 | .token.constant, 102 | .token.symbol, 103 | .token.deleted { 104 | color: #268bd2; /* blue */ 105 | } 106 | 107 | .token.selector, 108 | .token.attr-name, 109 | .token.string, 110 | .token.char, 111 | .token.builtin, 112 | .token.url, 113 | .token.inserted { 114 | color: #2aa198; /* cyan */ 115 | } 116 | 117 | .token.entity { 118 | color: #657b83; /* base00 */ 119 | background: #eee8d5; /* base2 */ 120 | } 121 | 122 | .token.atrule, 123 | .token.attr-value, 124 | .token.keyword { 125 | color: #859900; /* green */ 126 | } 127 | 128 | .token.function, 129 | .token.class-name { 130 | color: #b58900; /* yellow */ 131 | } 132 | 133 | .token.regex, 134 | .token.important, 135 | .token.variable { 136 | color: #cb4b16; /* orange */ 137 | } 138 | 139 | .token.important, 140 | .token.bold { 141 | font-weight: bold; 142 | } 143 | .token.italic { 144 | font-style: italic; 145 | } 146 | 147 | .token.entity { 148 | cursor: help; 149 | } 150 | -------------------------------------------------------------------------------- /themes/duotone-sea.css: -------------------------------------------------------------------------------- 1 | 2 | code[class*="language-"], 3 | pre[class*="language-"] { 4 | font-family: Hack, Consolas, Menlo, Monaco, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", "Courier New", Courier, monospace; 5 | font-size: 14px; 6 | line-height: 1.375; 7 | direction: ltr; 8 | text-align: left; 9 | white-space: pre; 10 | word-spacing: normal; 11 | word-break: normal; 12 | 13 | -moz-tab-size: 4; 14 | -o-tab-size: 4; 15 | tab-size: 4; 16 | 17 | -webkit-hyphens: none; 18 | -moz-hyphens: none; 19 | -ms-hyphens: none; 20 | hyphens: none; 21 | background: #1d262f; 22 | color: #57718e; 23 | } 24 | 25 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, 26 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 27 | text-shadow: none; 28 | background: #004a9e; 29 | } 30 | 31 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection, 32 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 33 | text-shadow: none; 34 | background: #004a9e; 35 | } 36 | 37 | pre[class*="language-"] { 38 | padding: 1em; 39 | margin: .5em 0; 40 | overflow: auto; 41 | } 42 | 43 | :not(pre) > code[class*="language-"] { 44 | padding: .1em; 45 | border-radius: .3em; 46 | } 47 | 48 | .token.comment, 49 | .token.prolog, 50 | .token.doctype, 51 | .token.cdata { 52 | color: #4a5f78; 53 | } 54 | 55 | .token.punctuation { 56 | color: #4a5f78; 57 | } 58 | 59 | .token.namespace { 60 | opacity: .7; 61 | } 62 | 63 | .token.tag, 64 | .token.operator, 65 | .token.number { 66 | color: #0aa370; 67 | } 68 | 69 | .token.property, 70 | .token.function { 71 | color: #57718e; 72 | } 73 | 74 | .token.tag-id, 75 | .token.selector, 76 | .token.atrule-id { 77 | color: #ebf4ff; 78 | } 79 | 80 | code.language-javascript, 81 | .token.attr-name { 82 | color: #7eb6f6; 83 | } 84 | 85 | code.language-css, 86 | code.language-scss, 87 | .token.boolean, 88 | .token.string, 89 | .token.entity, 90 | .token.url, 91 | .language-css .token.string, 92 | .language-scss .token.string, 93 | .style .token.string, 94 | .token.attr-value, 95 | .token.keyword, 96 | .token.control, 97 | .token.directive, 98 | .token.unit, 99 | .token.statement, 100 | .token.regex, 101 | .token.atrule { 102 | color: #47ebb4; 103 | } 104 | 105 | .token.placeholder, 106 | .token.variable { 107 | color: #47ebb4; 108 | } 109 | 110 | .token.deleted { 111 | text-decoration: line-through; 112 | } 113 | 114 | .token.inserted { 115 | border-bottom: 1px dotted #ebf4ff; 116 | text-decoration: none; 117 | } 118 | 119 | .token.italic { 120 | font-style: italic; 121 | } 122 | 123 | .token.important, 124 | .token.bold { 125 | font-weight: bold; 126 | } 127 | 128 | .token.important { 129 | color: #7eb6f6; 130 | } 131 | 132 | .token.entity { 133 | cursor: help; 134 | } 135 | 136 | pre > code.highlight { 137 | outline: .4em solid #34659d; 138 | outline-offset: .4em; 139 | } 140 | .line-numbers .line-numbers-rows { 141 | border-right-color: #1f2932; 142 | } 143 | 144 | .line-numbers-rows > span:before { 145 | color: #2c3847; 146 | } 147 | 148 | .line-highlight { 149 | background: rgba(10, 163, 112, 0.2); 150 | background: -webkit-linear-gradient(left, rgba(10, 163, 112, 0.2) 70%, rgba(10, 163, 112, 0)); 151 | background: linear-gradient(to right, rgba(10, 163, 112, 0.2) 70%, rgba(10, 163, 112, 0)); 152 | } 153 | -------------------------------------------------------------------------------- /themes/prism-twilight.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js Twilight theme 3 | * Based (more or less) on the Twilight theme originally of Textmate fame. 4 | * @author Remy Bach 5 | */ 6 | code[class*="language-"], 7 | pre[class*="language-"] { 8 | color: white; 9 | background: none; 10 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 11 | text-align: left; 12 | text-shadow: 0 -.1em .2em black; 13 | white-space: pre; 14 | word-spacing: normal; 15 | word-break: normal; 16 | word-wrap: normal; 17 | line-height: 1.5; 18 | 19 | -moz-tab-size: 4; 20 | -o-tab-size: 4; 21 | tab-size: 4; 22 | 23 | -webkit-hyphens: none; 24 | -moz-hyphens: none; 25 | -ms-hyphens: none; 26 | hyphens: none; 27 | } 28 | 29 | pre[class*="language-"], 30 | :not(pre) > code[class*="language-"] { 31 | background: hsl(0, 0%, 8%); /* #141414 */ 32 | } 33 | 34 | /* Code blocks */ 35 | pre[class*="language-"] { 36 | border-radius: .5em; 37 | border: .3em solid hsl(0, 0%, 33%); /* #282A2B */ 38 | box-shadow: 1px 1px .5em black inset; 39 | margin: .5em 0; 40 | overflow: auto; 41 | padding: 1em; 42 | } 43 | 44 | pre[class*="language-"]::-moz-selection { 45 | /* Firefox */ 46 | background: hsl(200, 4%, 16%); /* #282A2B */ 47 | } 48 | 49 | pre[class*="language-"]::selection { 50 | /* Safari */ 51 | background: hsl(200, 4%, 16%); /* #282A2B */ 52 | } 53 | 54 | /* Text Selection colour */ 55 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, 56 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 57 | text-shadow: none; 58 | background: hsla(0, 0%, 93%, 0.15); /* #EDEDED */ 59 | } 60 | 61 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection, 62 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 63 | text-shadow: none; 64 | background: hsla(0, 0%, 93%, 0.15); /* #EDEDED */ 65 | } 66 | 67 | /* Inline code */ 68 | :not(pre) > code[class*="language-"] { 69 | border-radius: .3em; 70 | border: .13em solid hsl(0, 0%, 33%); /* #545454 */ 71 | box-shadow: 1px 1px .3em -.1em black inset; 72 | padding: .15em .2em .05em; 73 | white-space: normal; 74 | } 75 | 76 | .token.comment, 77 | .token.prolog, 78 | .token.doctype, 79 | .token.cdata { 80 | color: hsl(0, 0%, 47%); /* #777777 */ 81 | } 82 | 83 | .token.punctuation { 84 | opacity: .7; 85 | } 86 | 87 | .namespace { 88 | opacity: .7; 89 | } 90 | 91 | .token.tag, 92 | .token.boolean, 93 | .token.number, 94 | .token.deleted { 95 | color: hsl(14, 58%, 55%); /* #CF6A4C */ 96 | } 97 | 98 | .token.keyword, 99 | .token.property, 100 | .token.selector, 101 | .token.constant, 102 | .token.symbol, 103 | .token.builtin { 104 | color: hsl(53, 89%, 79%); /* #F9EE98 */ 105 | } 106 | 107 | .token.attr-name, 108 | .token.attr-value, 109 | .token.string, 110 | .token.char, 111 | .token.operator, 112 | .token.entity, 113 | .token.url, 114 | .language-css .token.string, 115 | .style .token.string, 116 | .token.variable, 117 | .token.inserted { 118 | color: hsl(76, 21%, 52%); /* #8F9D6A */ 119 | } 120 | 121 | .token.atrule { 122 | color: hsl(218, 22%, 55%); /* #7587A6 */ 123 | } 124 | 125 | .token.regex, 126 | .token.important { 127 | color: hsl(42, 75%, 65%); /* #E9C062 */ 128 | } 129 | 130 | .token.important, 131 | .token.bold { 132 | font-weight: bold; 133 | } 134 | .token.italic { 135 | font-style: italic; 136 | } 137 | 138 | .token.entity { 139 | cursor: help; 140 | } 141 | 142 | pre[data-line] { 143 | padding: 1em 0 1em 3em; 144 | position: relative; 145 | } 146 | 147 | /* Markup */ 148 | .language-markup .token.tag, 149 | .language-markup .token.attr-name, 150 | .language-markup .token.punctuation { 151 | color: hsl(33, 33%, 52%); /* #AC885B */ 152 | } 153 | 154 | /* Make the tokens sit above the line highlight so the colours don't look faded. */ 155 | .token { 156 | position: relative; 157 | z-index: 1; 158 | } 159 | 160 | .line-highlight { 161 | background: hsla(0, 0%, 33%, 0.25); /* #545454 */ 162 | background: linear-gradient(to right, hsla(0, 0%, 33%, .1) 70%, hsla(0, 0%, 33%, 0)); /* #545454 */ 163 | border-bottom: 1px dashed hsl(0, 0%, 33%); /* #545454 */ 164 | border-top: 1px dashed hsl(0, 0%, 33%); /* #545454 */ 165 | left: 0; 166 | line-height: inherit; 167 | margin-top: 0.75em; /* Same as .prism’s padding-top */ 168 | padding: inherit 0; 169 | pointer-events: none; 170 | position: absolute; 171 | right: 0; 172 | white-space: pre; 173 | z-index: 0; 174 | } 175 | 176 | .line-highlight:before, 177 | .line-highlight[data-end]:after { 178 | background-color: hsl(215, 15%, 59%); /* #8794A6 */ 179 | border-radius: 999px; 180 | box-shadow: 0 1px white; 181 | color: hsl(24, 20%, 95%); /* #F5F2F0 */ 182 | content: attr(data-start); 183 | font: bold 65%/1.5 sans-serif; 184 | left: .6em; 185 | min-width: 1em; 186 | padding: 0 .5em; 187 | position: absolute; 188 | text-align: center; 189 | text-shadow: none; 190 | top: .4em; 191 | vertical-align: .3em; 192 | } 193 | 194 | .line-highlight[data-end]:after { 195 | bottom: .4em; 196 | content: attr(data-end); 197 | top: auto; 198 | } 199 | -------------------------------------------------------------------------------- /themes/prism-coy.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js Coy theme for JavaScript, CoffeeScript, CSS and HTML 3 | * Based on https://github.com/tshedor/workshop-wp-theme (Example: http://workshop.kansan.com/category/sessions/basics or http://workshop.timshedor.com/category/sessions/basics); 4 | * @author Tim Shedor 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: black; 10 | background: none; 11 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 12 | text-align: left; 13 | white-space: pre; 14 | word-spacing: normal; 15 | word-break: normal; 16 | word-wrap: normal; 17 | line-height: 1.5; 18 | 19 | -moz-tab-size: 4; 20 | -o-tab-size: 4; 21 | tab-size: 4; 22 | 23 | -webkit-hyphens: none; 24 | -moz-hyphens: none; 25 | -ms-hyphens: none; 26 | hyphens: none; 27 | } 28 | 29 | /* Code blocks */ 30 | pre[class*="language-"] { 31 | position: relative; 32 | margin: .5em 0; 33 | overflow: visible; 34 | padding: 0; 35 | } 36 | pre[class*="language-"]>code { 37 | position: relative; 38 | border-left: 10px solid #358ccb; 39 | box-shadow: -1px 0px 0px 0px #358ccb, 0px 0px 0px 1px #dfdfdf; 40 | background-color: #fdfdfd; 41 | background-image: linear-gradient(transparent 50%, rgba(69, 142, 209, 0.04) 50%); 42 | background-size: 3em 3em; 43 | background-origin: content-box; 44 | background-attachment: local; 45 | } 46 | 47 | code[class*="language"] { 48 | max-height: inherit; 49 | height: inherit; 50 | padding: 0 1em; 51 | display: block; 52 | overflow: auto; 53 | } 54 | 55 | /* Margin bottom to accomodate shadow */ 56 | :not(pre) > code[class*="language-"], 57 | pre[class*="language-"] { 58 | background-color: #fdfdfd; 59 | -webkit-box-sizing: border-box; 60 | -moz-box-sizing: border-box; 61 | box-sizing: border-box; 62 | margin-bottom: 1em; 63 | } 64 | 65 | /* Inline code */ 66 | :not(pre) > code[class*="language-"] { 67 | position: relative; 68 | padding: .2em; 69 | border-radius: 0.3em; 70 | color: #c92c2c; 71 | border: 1px solid rgba(0, 0, 0, 0.1); 72 | display: inline; 73 | white-space: normal; 74 | } 75 | 76 | pre[class*="language-"]:before, 77 | pre[class*="language-"]:after { 78 | content: ''; 79 | z-index: -2; 80 | display: block; 81 | position: absolute; 82 | bottom: 0.75em; 83 | left: 0.18em; 84 | width: 40%; 85 | height: 20%; 86 | max-height: 13em; 87 | box-shadow: 0px 13px 8px #979797; 88 | -webkit-transform: rotate(-2deg); 89 | -moz-transform: rotate(-2deg); 90 | -ms-transform: rotate(-2deg); 91 | -o-transform: rotate(-2deg); 92 | transform: rotate(-2deg); 93 | } 94 | 95 | :not(pre) > code[class*="language-"]:after, 96 | pre[class*="language-"]:after { 97 | right: 0.75em; 98 | left: auto; 99 | -webkit-transform: rotate(2deg); 100 | -moz-transform: rotate(2deg); 101 | -ms-transform: rotate(2deg); 102 | -o-transform: rotate(2deg); 103 | transform: rotate(2deg); 104 | } 105 | 106 | .token.comment, 107 | .token.block-comment, 108 | .token.prolog, 109 | .token.doctype, 110 | .token.cdata { 111 | color: #7D8B99; 112 | } 113 | 114 | .token.punctuation { 115 | color: #5F6364; 116 | } 117 | 118 | .token.property, 119 | .token.tag, 120 | .token.boolean, 121 | .token.number, 122 | .token.function-name, 123 | .token.constant, 124 | .token.symbol, 125 | .token.deleted { 126 | color: #c92c2c; 127 | } 128 | 129 | .token.selector, 130 | .token.attr-name, 131 | .token.string, 132 | .token.char, 133 | .token.function, 134 | .token.builtin, 135 | .token.inserted { 136 | color: #2f9c0a; 137 | } 138 | 139 | .token.operator, 140 | .token.entity, 141 | .token.url, 142 | .token.variable { 143 | color: #a67f59; 144 | background: rgba(255, 255, 255, 0.5); 145 | } 146 | 147 | .token.atrule, 148 | .token.attr-value, 149 | .token.keyword, 150 | .token.class-name { 151 | color: #1990b8; 152 | } 153 | 154 | .token.regex, 155 | .token.important { 156 | color: #e90; 157 | } 158 | 159 | .language-css .token.string, 160 | .style .token.string { 161 | color: #a67f59; 162 | background: rgba(255, 255, 255, 0.5); 163 | } 164 | 165 | .token.important { 166 | font-weight: normal; 167 | } 168 | 169 | .token.bold { 170 | font-weight: bold; 171 | } 172 | .token.italic { 173 | font-style: italic; 174 | } 175 | 176 | .token.entity { 177 | cursor: help; 178 | } 179 | 180 | .namespace { 181 | opacity: .7; 182 | } 183 | 184 | @media screen and (max-width: 767px) { 185 | pre[class*="language-"]:before, 186 | pre[class*="language-"]:after { 187 | bottom: 14px; 188 | box-shadow: none; 189 | } 190 | 191 | } 192 | 193 | /* Plugin styles */ 194 | .token.tab:not(:empty):before, 195 | .token.cr:before, 196 | .token.lf:before { 197 | color: #e0d7d1; 198 | } 199 | 200 | /* Plugin styles: Line Numbers */ 201 | pre[class*="language-"].line-numbers.line-numbers { 202 | padding-left: 0; 203 | } 204 | 205 | pre[class*="language-"].line-numbers.line-numbers code { 206 | padding-left: 3.8em; 207 | } 208 | 209 | pre[class*="language-"].line-numbers.line-numbers .line-numbers-rows { 210 | left: 0; 211 | } 212 | 213 | /* Plugin styles: Line Highlight */ 214 | pre[class*="language-"][data-line] { 215 | padding-top: 0; 216 | padding-bottom: 0; 217 | padding-left: 0; 218 | } 219 | pre[data-line] code { 220 | position: relative; 221 | padding-left: 4em; 222 | } 223 | pre .line-highlight { 224 | margin-top: 0; 225 | } 226 | -------------------------------------------------------------------------------- /demo/js/app.878e9d7a.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/App.vue?a176","webpack:///./src/App.vue?b4ce","webpack:///./src/CodeHighlight.vue?36aa","webpack:///src/CodeHighlight.vue","webpack:///./src/CodeHighlight.vue?3495","webpack:///./src/CodeHighlight.vue","webpack:///src/App.vue","webpack:///./src/App.vue?1160","webpack:///./src/App.vue?bff9","webpack:///./src/main.js"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","installedChunks","push","Object","prototype","hasOwnProperty","call","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","0","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","window","oldJsonpFunction","slice","_node_modules_mini_css_extract_plugin_dist_loader_js_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_lib_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default","Appvue_type_template_id_2d90a974_render","_vm","this","_h","$createElement","_c","_self","_v","staticRenderFns","CodeHighlightvue_type_template_id_18ebe8d4_render","ref","class","languageClass","_t","CodeHighlightvue_type_template_id_18ebe8d4_staticRenderFns","CodeHighlightvue_type_script_lang_js_","props","language","type","String","default","computed","concat","mounted","prism","highlightAllUnder","$refs","codeBlock","beforeUpdate","newText","$slots","text","replace","$el","querySelector","textContent","src_CodeHighlightvue_type_script_lang_js_","component","componentNormalizer","CodeHighlight","Appvue_type_script_lang_js_","components","dynamicCode","src_Appvue_type_script_lang_js_","App_component","App","vue_runtime_esm","config","productionTip","render","h","$mount"],"mappings":"aACA,SAAAA,EAAAC,GAQA,IAPA,IAMAC,EAAAC,EANAC,EAAAH,EAAA,GACAI,EAAAJ,EAAA,GACAK,EAAAL,EAAA,GAIAM,EAAA,EAAAC,KACQD,EAAAH,EAAAK,OAAoBF,IAC5BJ,EAAAC,EAAAG,GACAG,EAAAP,IACAK,EAAAG,KAAAD,EAAAP,GAAA,IAEAO,EAAAP,GAAA,EAEA,IAAAD,KAAAG,EACAO,OAAAC,UAAAC,eAAAC,KAAAV,EAAAH,KACAc,EAAAd,GAAAG,EAAAH,IAGAe,KAAAhB,GAEA,MAAAO,EAAAC,OACAD,EAAAU,OAAAV,GAOA,OAHAW,EAAAR,KAAAS,MAAAD,EAAAb,OAGAe,IAEA,SAAAA,IAEA,IADA,IAAAC,EACAf,EAAA,EAAiBA,EAAAY,EAAAV,OAA4BF,IAAA,CAG7C,IAFA,IAAAgB,EAAAJ,EAAAZ,GACAiB,GAAA,EACAC,EAAA,EAAkBA,EAAAF,EAAAd,OAA2BgB,IAAA,CAC7C,IAAAC,EAAAH,EAAAE,GACA,IAAAf,EAAAgB,KAAAF,GAAA,GAEAA,IACAL,EAAAQ,OAAApB,IAAA,GACAe,EAAAM,IAAAC,EAAAN,EAAA,KAGA,OAAAD,EAIA,IAAAQ,KAKApB,GACAqB,EAAA,GAGAZ,KAGA,SAAAS,EAAA1B,GAGA,GAAA4B,EAAA5B,GACA,OAAA4B,EAAA5B,GAAA8B,QAGA,IAAAC,EAAAH,EAAA5B,IACAK,EAAAL,EACAgC,GAAA,EACAF,YAUA,OANAhB,EAAAd,GAAAa,KAAAkB,EAAAD,QAAAC,IAAAD,QAAAJ,GAGAK,EAAAC,GAAA,EAGAD,EAAAD,QAKAJ,EAAAO,EAAAnB,EAGAY,EAAAQ,EAAAN,EAGAF,EAAAS,EAAA,SAAAL,EAAAM,EAAAC,GACAX,EAAAY,EAAAR,EAAAM,IACA1B,OAAA6B,eAAAT,EAAAM,GAA0CI,YAAA,EAAAC,IAAAJ,KAK1CX,EAAAgB,EAAA,SAAAZ,GACA,qBAAAa,eAAAC,aACAlC,OAAA6B,eAAAT,EAAAa,OAAAC,aAAwDC,MAAA,WAExDnC,OAAA6B,eAAAT,EAAA,cAAiDe,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAAnB,EAAAmB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,kBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAvC,OAAAwC,OAAA,MAGA,GAFAxB,EAAAgB,EAAAO,GACAvC,OAAA6B,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAAnB,EAAAS,EAAAc,EAAAE,EAAA,SAAAA,GAAgH,OAAAN,EAAAM,IAAqBC,KAAA,KAAAD,IACrI,OAAAF,GAIAvB,EAAA2B,EAAA,SAAAtB,GACA,IAAAM,EAAAN,KAAAiB,WACA,WAA2B,OAAAjB,EAAA,YAC3B,WAAiC,OAAAA,GAEjC,OADAL,EAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAgB,EAAAC,GAAsD,OAAA7C,OAAAC,UAAAC,eAAAC,KAAAyC,EAAAC,IAGtD7B,EAAA8B,EAAA,IAEA,IAAAC,EAAAC,OAAA,gBAAAA,OAAA,oBACAC,EAAAF,EAAAhD,KAAA2C,KAAAK,GACAA,EAAAhD,KAAAX,EACA2D,IAAAG,QACA,QAAAvD,EAAA,EAAgBA,EAAAoD,EAAAlD,OAAuBF,IAAAP,EAAA2D,EAAApD,IACvC,IAAAU,EAAA4C,EAIA1C,EAAAR,MAAA,MAEAU,2GCtJmZ0C,EAAA,uGCAnZC,EAAA,WAA0B,IAAAC,EAAAC,KAAaC,EAAAF,EAAAG,eAA0BC,EAAAJ,EAAAK,MAAAD,IAAAF,EAAwB,OAAAE,EAAA,kBAAAJ,EAAAM,GAAA,yRACzFC,KCDAC,EAAA,WAA0B,IAAAR,EAAAC,KAAaC,EAAAF,EAAAG,eAA0BC,EAAAJ,EAAAK,MAAAD,IAAAF,EAAwB,OAAAE,EAAA,OAAiBK,IAAA,cAAgBL,EAAA,OAAYM,MAAAV,EAAAW,gBAAwBP,EAAA,QAAAJ,EAAAY,GAAA,oBAC9JC,6BCQAC,GACAzC,KAAA,iBACA0C,OACAC,UACAC,KAAAC,OACAC,QAAA,eAGAC,UACAT,cADA,WAEA,kBAAAU,OAAApB,KAAAe,YAGAM,QAbA,WAcAC,EAAA,KAAAC,kBAAAvB,KAAAwB,MAAAC,YAGAC,aAjBA,WAkBA,IAAAC,EAAA3B,KAAA4B,OAAAV,QAAA,GAAAW,KAAAC,QAAA,6BACA9B,KAAA+B,IAAAC,cAAA,QAAAC,YAAAN,EACAL,EAAA,KAAAC,kBAAAvB,KAAAwB,MAAAC,aC7BqQS,EAAA,cCOrQC,EAAAzF,OAAA0F,EAAA,KAAA1F,CACAwF,EACA3B,EACAK,GACA,EACA,KACA,KACA,MAIAyB,EAAAF,UCCAG,GACAlE,KAAA,MACAmE,YACAF,iBAEAtG,KALA,WAMA,OACAyG,YAAA,iDC1B2PC,EAAA,ECQ3PC,aAAAhG,OAAA0F,EAAA,KAAA1F,CACA+F,EACA3C,EACAQ,GACA,EACA,KACA,KACA,OAIAqC,EAAAD,UChBAE,EAAA,KAAIC,OAAOC,eAAgB,EAE3B,IAAIF,EAAA,MACFG,OAAQ,SAAAC,GAAA,OAAKA,EAAEL,MACdM,OAAO","file":"js/app.878e9d7a.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t0: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([0,1]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","import mod from \"-!../node_modules/mini-css-extract-plugin/dist/loader.js!../node_modules/css-loader/index.js??ref--6-oneOf-1-1!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/postcss-loader/lib/index.js??ref--6-oneOf-1-2!../node_modules/cache-loader/dist/cjs.js??ref--0-0!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=style&index=0&lang=css&\"; export default mod; export * from \"-!../node_modules/mini-css-extract-plugin/dist/loader.js!../node_modules/css-loader/index.js??ref--6-oneOf-1-1!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/postcss-loader/lib/index.js??ref--6-oneOf-1-2!../node_modules/cache-loader/dist/cjs.js??ref--0-0!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=style&index=0&lang=css&\"","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('code-highlight',[_vm._v(\"\\n let isPalindrome = (word) => {\\n let [length, result] = [word.length, true];\\n\\n for (let i = 0; i < length / 2; i++) {\\n if (word[i] !== word[length - 1 - i]) result = false;\\n }\\n return result;\\n }\\n\\n module.exports = isPalindrome;\\n\")])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:\"codeBlock\"},[_c('pre',{class:_vm.languageClass},[_c('code',[_vm._t(\"default\")],2)])])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n","import mod from \"-!../node_modules/cache-loader/dist/cjs.js??ref--12-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js??vue-loader-options!./CodeHighlight.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../node_modules/cache-loader/dist/cjs.js??ref--12-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js??vue-loader-options!./CodeHighlight.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./CodeHighlight.vue?vue&type=template&id=18ebe8d4&\"\nimport script from \"./CodeHighlight.vue?vue&type=script&lang=js&\"\nexport * from \"./CodeHighlight.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports","\n\n\n\n\n","import mod from \"-!../node_modules/cache-loader/dist/cjs.js??ref--12-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../node_modules/cache-loader/dist/cjs.js??ref--12-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./App.vue?vue&type=template&id=2d90a974&\"\nimport script from \"./App.vue?vue&type=script&lang=js&\"\nexport * from \"./App.vue?vue&type=script&lang=js&\"\nimport style0 from \"./App.vue?vue&type=style&index=0&lang=css&\"\n\n\n/* normalize component */\nimport normalizer from \"!../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports","import Vue from 'vue';\nimport App from './App.vue';\n\nVue.config.productionTip = false;\n\nnew Vue({\n render: h => h(App),\n}).$mount('#app');\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /dist/vue-code-highlight.esm.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /* ********************************************** 3 | Begin prism-core.js 4 | ********************************************** */ 5 | 6 | var _self = {}; 7 | 8 | /** 9 | * Prism: Lightweight, robust, elegant syntax highlighting 10 | * MIT license http://www.opensource.org/licenses/mit-license.php/ 11 | * @author Lea Verou http://lea.verou.me 12 | */ 13 | 14 | var Prism = (function () { 15 | // Private helper vars 16 | var lang = /\blang(?:uage)?-([\w-]+)\b/i; 17 | var uniqueId = 0; 18 | 19 | var _ = _self.Prism = { 20 | manual: _self.Prism && _self.Prism.manual, 21 | disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, 22 | util: { 23 | encode: function encode (tokens) { 24 | if (tokens instanceof Token) { 25 | return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); 26 | } else if (_.util.type(tokens) === 'Array') { 27 | return tokens.map(_.util.encode); 28 | } else { 29 | return tokens.replace(/&/g, '&').replace(/ text.length) { 321 | // Something went terribly wrong, ABORT, ABORT! 322 | return; 323 | } 324 | 325 | if (str instanceof Token) { 326 | continue; 327 | } 328 | 329 | if (greedy && i != strarr.length - 1) { 330 | pattern.lastIndex = pos; 331 | var match = pattern.exec(text); 332 | if (!match) { 333 | break; 334 | } 335 | 336 | var from = match.index + (lookbehind ? match[1].length : 0), 337 | to = match.index + match[0].length, 338 | k = i, 339 | p = pos; 340 | 341 | for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) { 342 | p += strarr[k].length; 343 | // Move the index i to the element in strarr that is closest to from 344 | if (from >= p) { 345 | ++i; 346 | pos = p; 347 | } 348 | } 349 | 350 | // If strarr[i] is a Token, then the match starts inside another Token, which is invalid 351 | if (strarr[i] instanceof Token) { 352 | continue; 353 | } 354 | 355 | // Number of tokens to delete and replace with the new match 356 | delNum = k - i; 357 | str = text.slice(pos, p); 358 | match.index -= pos; 359 | } else { 360 | pattern.lastIndex = 0; 361 | 362 | var match = pattern.exec(str), 363 | delNum = 1; 364 | } 365 | 366 | if (!match) { 367 | if (oneshot) { 368 | break; 369 | } 370 | 371 | continue; 372 | } 373 | 374 | if(lookbehind) { 375 | lookbehindLength = match[1] ? match[1].length : 0; 376 | } 377 | 378 | var from = match.index + lookbehindLength, 379 | match = match[0].slice(lookbehindLength), 380 | to = from + match.length, 381 | before = str.slice(0, from), 382 | after = str.slice(to); 383 | 384 | var args = [i, delNum]; 385 | 386 | if (before) { 387 | ++i; 388 | pos += before.length; 389 | args.push(before); 390 | } 391 | 392 | var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy); 393 | 394 | args.push(wrapped); 395 | 396 | if (after) { 397 | args.push(after); 398 | } 399 | 400 | Array.prototype.splice.apply(strarr, args); 401 | 402 | if (delNum != 1) 403 | { _.matchGrammar(text, strarr, grammar, i, pos, true, token); } 404 | 405 | if (oneshot) 406 | { break; } 407 | } 408 | } 409 | } 410 | }, 411 | 412 | tokenize: function tokenize(text, grammar, language) { 413 | var strarr = [text]; 414 | 415 | var rest = grammar.rest; 416 | 417 | if (rest) { 418 | for (var token in rest) { 419 | grammar[token] = rest[token]; 420 | } 421 | 422 | delete grammar.rest; 423 | } 424 | 425 | _.matchGrammar(text, strarr, grammar, 0, 0, false); 426 | 427 | return strarr; 428 | }, 429 | 430 | hooks: { 431 | all: {}, 432 | 433 | add: function add (name, callback) { 434 | var hooks = _.hooks.all; 435 | 436 | hooks[name] = hooks[name] || []; 437 | 438 | hooks[name].push(callback); 439 | }, 440 | 441 | run: function run (name, env) { 442 | var callbacks = _.hooks.all[name]; 443 | 444 | if (!callbacks || !callbacks.length) { 445 | return; 446 | } 447 | 448 | for (var i=0, callback; callback = callbacks[i++];) { 449 | callback(env); 450 | } 451 | }, 452 | }, 453 | }; 454 | 455 | var Token = _.Token = function (type, content, alias, matchedStr, greedy) { 456 | this.type = type; 457 | this.content = content; 458 | this.alias = alias; 459 | // Copy of the full string this token was created from 460 | this.length = (matchedStr || '').length | 0; 461 | this.greedy = !!greedy; 462 | }; 463 | 464 | Token.stringify = function (o, language, parent) { 465 | if (typeof o === 'string') { 466 | return o; 467 | } 468 | 469 | if (_.util.type(o) === 'Array') { 470 | return o.map(function (element) { 471 | return Token.stringify(element, language, o); 472 | }).join(''); 473 | } 474 | 475 | var env = { 476 | type: o.type, 477 | content: Token.stringify(o.content, language, parent), 478 | tag: 'span', 479 | classes: ['token', o.type], 480 | attributes: {}, 481 | language: language, 482 | parent: parent, 483 | }; 484 | 485 | if (o.alias) { 486 | var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias]; 487 | Array.prototype.push.apply(env.classes, aliases); 488 | } 489 | 490 | _.hooks.run('wrap', env); 491 | 492 | var attributes = Object.keys(env.attributes).map(function (name) { 493 | return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; 494 | }).join(' '); 495 | 496 | return ("<" + (env.tag) + " class=\"" + (env.classes.join(' ')) + "\"" + (attributes ? ' ' + attributes : '') + ">" + (env.content) + ""); 497 | }; 498 | 499 | if (!_self.document) { 500 | if (!_self.addEventListener) { 501 | // in Node.js 502 | return _self.Prism; 503 | } 504 | 505 | if (!_.disableWorkerMessageHandler) { 506 | // In worker 507 | _self.addEventListener('message', function (evt) { 508 | var message = JSON.parse(evt.data), 509 | lang = message.language, 510 | code = message.code, 511 | immediateClose = message.immediateClose; 512 | 513 | _self.postMessage(_.highlight(code, _.languages[lang], lang)); 514 | if (immediateClose) { 515 | _self.close(); 516 | } 517 | }, false); 518 | } 519 | 520 | return _self.Prism; 521 | } 522 | 523 | // Get current script and highlight 524 | // let script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop(); 525 | 526 | // if (script) { 527 | // _.filename = script.src; 528 | 529 | // if (!_.manual && !script.hasAttribute('data-manual')) { 530 | // if (document.readyState !== 'loading') { 531 | // if (window.requestAnimationFrame) { 532 | // window.requestAnimationFrame(_.highlightAll); 533 | // } else { 534 | // window.setTimeout(_.highlightAll, 16); 535 | // } 536 | // } else { 537 | // document.addEventListener('DOMContentLoaded', _.highlightAll); 538 | // } 539 | // } 540 | // } 541 | 542 | return _self.Prism; 543 | }()); 544 | 545 | if (typeof module !== 'undefined' && module.exports) { 546 | module.exports = Prism; 547 | } 548 | 549 | // hack for components to work correctly in node.js 550 | if (typeof global !== 'undefined') { 551 | global.Prism = Prism; 552 | } 553 | 554 | 555 | /* ********************************************** 556 | Begin prism-markup.js 557 | ********************************************** */ 558 | 559 | Prism.languages.markup = { 560 | comment: //, 561 | prolog: /<\?[\s\S]+?\?>/, 562 | doctype: //i, 563 | cdata: //i, 564 | tag: { 565 | pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i, 566 | greedy: true, 567 | inside: { 568 | tag: { 569 | pattern: /^<\/?[^\s>\/]+/i, 570 | inside: { 571 | punctuation: /^<\/?/, 572 | namespace: /^[^\s>\/:]+:/, 573 | }, 574 | }, 575 | 'attr-value': { 576 | pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i, 577 | inside: { 578 | punctuation: [ 579 | /^=/, 580 | { 581 | pattern: /(^|[^\\])["']/, 582 | lookbehind: true, 583 | } ], 584 | }, 585 | }, 586 | punctuation: /\/?>/, 587 | 'attr-name': { 588 | pattern: /[^\s>\/]+/, 589 | inside: { 590 | namespace: /^[^\s>\/:]+:/, 591 | }, 592 | }, 593 | 594 | }, 595 | }, 596 | entity: /&#?[\da-z]{1,8};/i, 597 | }; 598 | 599 | Prism.languages.markup.tag.inside['attr-value'].inside.entity = Prism.languages.markup.entity; 600 | 601 | // Plugin to make entity title show the real entity, idea by Roman Komarov 602 | Prism.hooks.add('wrap', function (env) { 603 | 604 | if (env.type === 'entity') { 605 | env.attributes['title'] = env.content.replace(/&/, '&'); 606 | } 607 | }); 608 | 609 | Prism.languages.xml = Prism.languages.markup; 610 | Prism.languages.html = Prism.languages.markup; 611 | Prism.languages.mathml = Prism.languages.markup; 612 | Prism.languages.svg = Prism.languages.markup; 613 | 614 | 615 | /* ********************************************** 616 | Begin prism-css.js 617 | ********************************************** */ 618 | 619 | Prism.languages.css = { 620 | comment: /\/\*[\s\S]*?\*\//, 621 | atrule: { 622 | pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i, 623 | inside: { 624 | rule: /@[\w-]+/, 625 | // See rest below 626 | }, 627 | }, 628 | url: /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, 629 | selector: /[^{}\s][^{};]*?(?=\s*\{)/, 630 | string: { 631 | pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 632 | greedy: true, 633 | }, 634 | property: /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, 635 | important: /\B!important\b/i, 636 | function: /[-a-z0-9]+(?=\()/i, 637 | punctuation: /[(){};:]/, 638 | }; 639 | 640 | Prism.languages.css.atrule.inside.rest = Prism.languages.css; 641 | 642 | if (Prism.languages.markup) { 643 | Prism.languages.insertBefore('markup', 'tag', { 644 | style: { 645 | pattern: /()[\s\S]*?(?=<\/style>)/i, 646 | lookbehind: true, 647 | inside: Prism.languages.css, 648 | alias: 'language-css', 649 | greedy: true, 650 | }, 651 | }); 652 | 653 | Prism.languages.insertBefore('inside', 'attr-value', { 654 | 'style-attr': { 655 | pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, 656 | inside: { 657 | 'attr-name': { 658 | pattern: /^\s*style/i, 659 | inside: Prism.languages.markup.tag.inside, 660 | }, 661 | punctuation: /^\s*=\s*['"]|['"]\s*$/, 662 | 'attr-value': { 663 | pattern: /.+/i, 664 | inside: Prism.languages.css, 665 | }, 666 | }, 667 | alias: 'language-css', 668 | }, 669 | }, Prism.languages.markup.tag); 670 | } 671 | 672 | /* ********************************************** 673 | Begin prism-clike.js 674 | ********************************************** */ 675 | 676 | Prism.languages.clike = { 677 | comment: [ 678 | { 679 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 680 | lookbehind: true, 681 | }, 682 | { 683 | pattern: /(^|[^\\:])\/\/.*/, 684 | lookbehind: true, 685 | greedy: true, 686 | } ], 687 | string: { 688 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 689 | greedy: true, 690 | }, 691 | 'class-name': { 692 | pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, 693 | lookbehind: true, 694 | inside: { 695 | punctuation: /[.\\]/, 696 | }, 697 | }, 698 | keyword: /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 699 | boolean: /\b(?:true|false)\b/, 700 | function: /[a-z0-9_]+(?=\()/i, 701 | number: /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, 702 | operator: /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, 703 | punctuation: /[{}[\];(),.:]/, 704 | }; 705 | 706 | 707 | /* ********************************************** 708 | Begin prism-javascript.js 709 | ********************************************** */ 710 | 711 | Prism.languages.javascript = Prism.languages.extend('clike', { 712 | keyword: /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/, 713 | number: /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, 714 | // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) 715 | function: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i, 716 | operator: /-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/, 717 | }); 718 | 719 | Prism.languages.insertBefore('javascript', 'keyword', { 720 | regex: { 721 | pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, 722 | lookbehind: true, 723 | greedy: true, 724 | }, 725 | // This must be declared before keyword because we use "function" inside the look-forward 726 | 'function-variable': { 727 | pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, 728 | alias: 'function', 729 | }, 730 | constant: /\b[A-Z][A-Z\d_]*\b/, 731 | }); 732 | 733 | Prism.languages.insertBefore('javascript', 'string', { 734 | 'template-string': { 735 | pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, 736 | greedy: true, 737 | inside: { 738 | interpolation: { 739 | pattern: /\${[^}]+}/, 740 | inside: { 741 | 'interpolation-punctuation': { 742 | pattern: /^\${|}$/, 743 | alias: 'punctuation', 744 | }, 745 | rest: null, // See below 746 | }, 747 | }, 748 | string: /[\s\S]+/, 749 | }, 750 | }, 751 | }); 752 | Prism.languages.javascript['template-string'].inside.interpolation.inside.rest = Prism.languages.javascript; 753 | 754 | if (Prism.languages.markup) { 755 | Prism.languages.insertBefore('markup', 'tag', { 756 | script: { 757 | pattern: /()[\s\S]*?(?=<\/script>)/i, 758 | lookbehind: true, 759 | inside: Prism.languages.javascript, 760 | alias: 'language-javascript', 761 | greedy: true, 762 | }, 763 | }); 764 | } 765 | 766 | Prism.languages.js = Prism.languages.javascript; 767 | 768 | (function(){ if(typeof document !== 'undefined'){ var head=document.head||document.getElementsByTagName('head')[0], style=document.createElement('style'), css=""; style.type='text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); } })(); 769 | 770 | var CodeHighlight = {render: function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"codeBlock"},[_c('pre',{class:_vm.languageClass},[_c('code',[_vm._t("default")],2)])])},staticRenderFns: [], 771 | name: 'code-highlight', 772 | props: { 773 | language: { 774 | type: String, 775 | default: 'javascript', 776 | }, 777 | }, 778 | computed: { 779 | languageClass: function languageClass() { 780 | return ("language-" + (this.language)); 781 | }, 782 | }, 783 | mounted: function mounted() { 784 | Prism.highlightAllUnder(this.$refs.codeBlock); 785 | }, 786 | 787 | beforeUpdate: function beforeUpdate() { 788 | if(this.$slots.default[0].text){ 789 | var newText = this.$slots.default[0].text.replace(/^[\r\n\s]*|[\r\n\s]*$/g, ''); 790 | this.$el.querySelector('code').textContent = newText; 791 | Prism.highlightAllUnder(this.$refs.codeBlock); 792 | } 793 | }, 794 | }; 795 | 796 | function registerDirective (el) { 797 | Prism.highlightAllUnder(el); 798 | } 799 | 800 | // Import vue component 801 | 802 | // Declare install function executed by Vue.use() 803 | function install(Vue) { 804 | if (install.installed) { return; } 805 | install.installed = true; 806 | Vue.directive('highlight', registerDirective); 807 | } 808 | 809 | // Create module definition for Vue.use() 810 | var plugin = { 811 | install: install, 812 | }; 813 | 814 | // Auto-install when vue is found (eg. in browser via