mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
description of code notes and how to add more languages
parent
4977eee024
commit
1353389870
36
Code notes.md
Normal file
36
Code notes.md
Normal file
@ -0,0 +1,36 @@
|
||||
Trilium supports creating "code" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).
|
||||
|
||||
This can be useful for few things:
|
||||
|
||||
* computer programmers can store code snippets as notes with syntax highlighting
|
||||
* JavaScript code notes can be executed inside Trilium for some extra functionality
|
||||
* we call such JavaScript code notes "scripts" - see [[Scripts]]
|
||||
* JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)
|
||||
|
||||
[[images/code-note.png]]
|
||||
|
||||
## 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 use [[Script API]]:
|
||||
|
||||
```javascript
|
||||
const codeMimeTypes = api.getDefaultCodeMimeTypes();
|
||||
codeMimeTypes.push({
|
||||
mime: "text/x-ocaml",
|
||||
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).
|
||||
|
||||
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`.
|
@ -1,11 +1,4 @@
|
||||
Trilium supports creating "code" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).
|
||||
|
||||
This can be useful for few things:
|
||||
|
||||
* computer programmers can store code snippets as notes
|
||||
* JavaScript code notes can be executed inside Trilium for some extra functionality
|
||||
* we call such JavaScript code notes "scripts"
|
||||
* JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)
|
||||
Trilium supports creating [[code notes]], i.e. notes which allow you to store some programming code and highlight it. Special case is JavaScript code notes which can also be executed inside Trilium which can in conjunction with [[Script API]] provide extra functionality.
|
||||
|
||||
## Scripting
|
||||
|
||||
|
@ -27,7 +27,8 @@
|
||||
* [[Attribute inheritance]]
|
||||
* [[Promoted attributes]]
|
||||
* [[Template]]
|
||||
* [[Scripts]]
|
||||
* [[Code notes]]
|
||||
* [[Scripts]]
|
||||
* [[Script API]]
|
||||
* [[Events]]
|
||||
* [[Advanced showcases]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user