You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tool provides you the ability to create highlighted code for Microsoft Office, mainly for Word and PowerPoint. You can use it to create a beautiful code block in your document or presentation.
11
+
This tool provides you the ability to create highlighted code block for Microsoft Office, mainly for Word and PowerPoint. You can use it to create a beautiful code block in your document or presentation.
10
12
11
13
### Try it now!
12
14
@@ -17,38 +19,53 @@ This tool provides you the ability to create highlighted code for Microsoft Offi
17
19
18
20
## Development
19
21
20
-
If you find Code Paste useful and want to host it on your website, this section will be useful.
21
-
22
-
> **NOTICE:** I'm glad some of you have already hosted Code Paste on you own server, but forgot to remove the analytics scripts and my COS links. It's partly due to my bad project structure, so I refactored it to separate these configurations. Besides, **I would appreciate it if you mention my repository in your website**.🙏
23
-
24
-
Feel free to contribute to this project. You can report bugs, suggest new features, or even submit a pull request. 😊
22
+
If you find Code Paste useful and want to host it on your own, this section will be useful. By the way, feel free to contribute to this project. You can report bugs, suggest new features, or even submit a pull request. 😊
25
23
26
24
### Quick Start
27
25
28
-
Code Paste is written in native HTML, CSS and JavaScript with npm and Webpack. Also with posthtml for the `<module>` tag. To start development, clone the repo first, then install required packages.
26
+
Code Paste is written in native HTML, CSS and JavaScript. To start development, clone the repo first, then install required packages.
29
27
30
28
```bash
31
29
npm install
32
-
npm run init # initialize placeholder
30
+
npm run init # initialize placeholder files
33
31
```
34
32
35
33
Then, you can run the project. There are three options for this.
36
34
37
35
```bash
38
36
npm run build # build for production
39
-
npm run dev # build for development
40
-
npm run watch # build for development and watch for changes
37
+
npm run dev # build for development and watch for changes
41
38
```
42
39
43
40
> To preview the project locally, I recommend using [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) plugin for Visual Studio Code. Just open `dist/index.html` after your local server is on.
44
41
42
+
### Code Samples
43
+
44
+
Code Paste provides sample code for each supported language. The supported languages are listed in `languages/lang.yml`, grouped by their categories. All the code samples are placed under `languages/samples/` directory.
45
+
46
+
> [!NOTE]
47
+
>
48
+
> The display order of the language options in the final webpage is exactly the same as that in `lang.yml`.
49
+
50
+
Managing language options in HTML and JavaScript is tedious, so there is a script to automatically generate related code. You should run this command after modifying the language list or adding new samples. This will generate `src/js/samples.js` and `src/views/components/languages.html`.
51
+
52
+
```bash
53
+
npm run sample
54
+
```
55
+
56
+
To add a new language, first add it to `languages/lang.yml`. In the suitable category, add a new list item in the format of `key value`, where `key` is the language id of [Prism.js](https://prismjs.com/#supported-languages), and the `value` is the display name of the language in the select box. Then, create a new file `{key}.txt` under `languages/samples/` and write your sample code in it. Finally, add this language to `.babelrc` so that it can be correctly loaded.
57
+
58
+
> [!WARNING]
59
+
>
60
+
> `npm run dev` will not watch for changes under `languages/` directory. So you have to manually update it.
61
+
45
62
### Customization
46
63
47
-
Since I removed sensitive information from the project, you need to run `npm run init` to create placeholder files even if you don't need them. They are under `src/views/components/`, where you can find a `.gitignore` that ignores them.
64
+
Since I removed sensitive information from the project, you need to run `npm run init` to create placeholder files even if you don't need them. These files are placed under `src/views/components/`.
48
65
49
66
**Analytics**
50
67
51
-
In file `statistics.html`, and place all your scripts into it. If you don't need them, just leave this file empty. The file should look like this.
68
+
In file `statistics.html`, and place all your scripts into it. If you don't need them, just leave this file empty. Here is an example for this file.
52
69
53
70
```html
54
71
<!-- Clarity -->
@@ -59,7 +76,7 @@ In file `statistics.html`, and place all your scripts into it. If you don't need
59
76
y =l.getElementsByTagName(r)[0]; y.parentNode.insertBefore(t, y);
0 commit comments