Skip to content

Commit 11ac251

Browse files
author
Jan Bílek
committed
Fill readme and move themes
1 parent 140f9c0 commit 11ac251

File tree

12 files changed

+67
-1
lines changed

12 files changed

+67
-1
lines changed

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,62 @@
33
> Beautiful code syntax highlighting as Vue.js component.
44
55
## Usage
6-
Work in progress.
6+
7+
```
8+
npm install vue-code-highlight --save
9+
```
10+
11+
Now, you can use this module in two diferrent ways, as a component or as a directive.
12+
13+
### Component
14+
In any component:
15+
16+
```
17+
// You have to extract the component from the module
18+
import { component as VueCodeHighlight } from 'vue-code-highlight';
19+
20+
components:{
21+
VueCodeHighlight,
22+
...
23+
}
24+
```
25+
26+
```
27+
<vue-code-highlight>
28+
//Paste your code here
29+
</vue-code-highlight>
30+
```
31+
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.)
32+
33+
### Directive
34+
In your main file:
35+
```js
36+
import VueCodeHighlight from 'vue-code-highlight';
37+
38+
Vue.use(VueCodeHighlight) //registers the v-highlight directive
39+
40+
```
41+
And then in any Vue component:
42+
43+
```html
44+
<article v-highlight >
45+
...
46+
</article>
47+
```
48+
Every node under the article component having the following structure will be syntax highlighted.
49+
50+
```html
51+
<pre class="language-javascript">
52+
<code>
53+
//your code goes here
54+
</code>
55+
</pre>
56+
```
57+
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.
58+
59+
### Themes
60+
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.
61+
762

863
## Examples:
964
![screenshot](/src/assets/screenshot.png)

src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<script>
1919
2020
import CodeHighlight from './CodeHighlight.vue';
21+
import '../themes/duotone-sea.css';
2122
2223
export default {
2324
name: 'app',

0 commit comments

Comments
 (0)