├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── .travis.yml ├── README.md ├── index.js ├── package.json └── test └── index.test.js /.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 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": "eslint-config-es5", 3 | "plugins": [ 4 | "import" 5 | ], 6 | "rules": { 7 | "strict": [0, "global"], 8 | "no-var": "off" 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: "6" 3 | install: npm install -d 4 | script: 5 | - npm run lint 6 | - npm test 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-highlightjs 2 | 3 | **This project is superseded by the official Highlight.js Vue plugin:** 4 | 5 | * https://github.com/highlightjs/vue-plugin 6 | * https://www.npmjs.com/package/@highlightjs/vue-plugin 7 | 8 | --- 9 | 10 | [Vue.js](https://vuejs.org/) syntax highlighting made easy, using [highlight.js](https://highlightjs.org/). 11 | 12 | [](https://travis-ci.org/metachris/vue-highlightjs) 13 | 14 | ## Quickstart 15 | 16 | ### Installation 17 | 18 | Simply install the [npm package `vue-highlightjs`](https://www.npmjs.com/package/vue-highlightjs): 19 | 20 | npm install --save vue-highlightjs 21 | 22 | ### Using vue-highlightjs 23 | 24 | In your main JavaScript file (eg. `main.js`): 25 | 26 | ```javascript 27 | // Import Vue and vue-highlgihtjs 28 | import Vue from 'vue' 29 | import VueHighlightJS from 'vue-highlightjs' 30 | import 'highlight.js/styles/default.css' // or other highlight.js theme 31 | 32 | // Tell Vue.js to use vue-highlightjs 33 | Vue.use(VueHighlightJS) 34 | ``` 35 | 36 | In your template, in order to highlight javascript code: 37 | 38 | ```html 39 | 40 |
41 |
42 |
43 | const s = new Date().toString()
44 | ```
45 | ---
46 |
47 | * You can see a live example here: https://www.python-boilerplate.com/
48 | * Fiddle with it: https://jsfiddle.net/metachris/1vz9oobc/
49 | * See also this blog post for more information: https://www.metachris.com/2017/02/vuejs-syntax-highlighting-with-highlightjs/
50 |
51 |
52 | ## Contributing
53 |
54 | Any sort of contributions and feedback is much appreciated. Just
55 | leave an issue or pull-request!
56 |
57 | This project uses the [AirBnB code style](https://github.com/airbnb/javascript).
58 |
59 | Please run `npm run lint` and `npm run test` before you submit a pull request! <3
60 |
61 |
62 | ## About
63 |
64 | Author: Chris Hager // Static source code
10 | function(test) {
11 | console.log(test)
12 | }
13 |
35 | 123
');
57 | });
58 | });
59 |
60 | it('should updated highlighted block when updating code without any content', () => {
61 | vm.sourcecode = '';
62 | Vue.nextTick(function () {
63 | result = vm.$el.innerHTML;
64 | // console.log('result', result);
65 | expect(result).toEqual('
');
66 | });
67 | });
68 | });
69 |
70 |
71 | describe('highlighting code within dynamic content', () => {
72 | let vm, result;
73 |
74 | beforeEach(() => {
75 | const template = `
76 |
',
85 | },
86 | }).$mount();
87 | });
88 |
89 | it('should updated highlighted block when updating code without any content', () => {
90 | vm.sourcecode = '
';
91 | Vue.nextTick(function () {
92 | result = vm.$el.innerHTML;
93 | // console.log('result', result);
94 | expect(result).toEqual('