mirror of
https://github.com/zadam/trilium.git
synced 2024-12-27 01:34:05 +08:00
Updated Code notes (markdown)
parent
e897013f28
commit
df62605ebe
1 changed files with 7 additions and 18 deletions
|
@ -11,26 +11,15 @@ This can be useful for few things:
|
||||||
|
|
||||||
## Extra languages
|
## Extra languages
|
||||||
|
|
||||||
Trilium supports syntax highlighting for many languages, but by default displays only some of them (to reduce number of items). If you want to add some unlisted supported language, you can add them by creating new frontend JavaScript code note and using [[Script API]]:
|
Trilium supports syntax highlighting for many languages, but by default displays only some of them (to reduce number of items). To add some extra languages create a JSON code note with label `codeMimeTypes`:
|
||||||
|
|
||||||
```javascript
|
```json
|
||||||
const codeMimeTypes = api.getDefaultCodeMimeTypes();
|
[
|
||||||
codeMimeTypes.push({
|
{ "mime": "text/x-ocaml", "title": "OCaml" },
|
||||||
mime: "text/x-ocaml",
|
{ "mime": "text/x-rsrc", "title": "R" }
|
||||||
title: "OCaml"
|
]
|
||||||
});
|
|
||||||
|
|
||||||
codeMimeTypes.push({
|
|
||||||
mime: "text/x-rsrc",
|
|
||||||
title: "R"
|
|
||||||
});
|
|
||||||
|
|
||||||
// sort alphabetically
|
|
||||||
codeMimeTypes.sort((a, b) => a.title > b.title ? 1 : -1);
|
|
||||||
|
|
||||||
api.setCodeMimeTypes(codeMimeTypes);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
To get correct mime type for your language see [list of language modes](https://codemirror.net/mode/) for CodeMirror (code editor component used in Trilium).
|
To get correct mime type for your language see [list of language modes](https://codemirror.net/mode/) for CodeMirror (code editor component used in Trilium).
|
||||||
|
|
||||||
Add [[label|attributes]] `run` with value `frontendStartup` so that desired languages are added to the list on every startup. For changes to take effect, click on "run" button or reload Trilium's frontend with `CTRL-R`.
|
Note that this functionality is provided since Trilium v0.35. For changes to take effect, click on "run" button or reload Trilium's frontend with `CTRL-R`.
|
||||||
|
|
Loading…
Reference in a new issue