Skip to content

Commit 73e5cbd

Browse files
committed
Release 1.4.5
1 parent 66ad583 commit 73e5cbd

14 files changed

Lines changed: 381 additions & 276 deletions

Changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
- 1.4.5 (2026.03.31)
2+
- New
3+
- Added option to define PrismJS syntax highlighting rules for custom languages (#157)
4+
15
- 1.4.4 (2026.03.25)
26
- Modified:
37
- Added Mac support for modifier keys

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The plugin lets you customize the code blocks in the following way:
3535
- **NEW:** New blur effect for semi-fold
3636
- **NEW:** Syntax Themes. Using this you can define each color for syntax highlighting tokens. Read more below.
3737
- **NEW:** Added customizable frontmatter syntax coloring in editing mode
38+
- **NEW:** Added option to define PrismJS syntax highlighting rules for custom languages
3839
- and much more...
3940

4041
For a more detailed list of changes, check the [Changelog](./Changelog.txt).
@@ -63,6 +64,7 @@ For a more detailed list of changes, check the [Changelog](./Changelog.txt).
6364
- [Indented Code Blocks](#indented-code-blocks)
6465
- [Links](#links)
6566
- [Custom SVGs and Syntax Highlight Assignment](#custom-svgs-and-syntax-highlight-assignment)
67+
- [Syntax Highlighting for Custom Languages](#syntax-highlighting-for-custom-languages)
6668
- [Bracket Highlight](#bracket-highlight)
6769
- [Selection Matching](#selection-matching)
6870
- [Plugin Compatibility](#plugin-compatibility)
@@ -617,6 +619,62 @@ An example using the above shown JSON file, where `tcl` syntax highlighting is a
617619

618620
![Pasted_image_20240613160326.png](attachments/Pasted_image_20240613160326.png)
619621

622+
## Syntax Highlighting for Custom Languages
623+
624+
`PrismJS` provides syntax highlighting for a lot of languages, but there are still some, which it doesn't support. This feature lets you define your own syntax highlighting rules for those unsupported languages by creating a JSON configuration file. If `Use PrismJS for syntax highlighting in editor mode` is enabled (see [PrismJS Syntax Highlighting](#prismjs-syntax-highlighting)), the rules apply in both editor and reading mode. If it is not enabled, the rules will only apply in reading mode.
625+
626+
To get started, create a `customPrismLanguages.json` file in your `<VaultFolder>\.obsidian\plugins\codeblock-customizer\` folder. In this file you can define the RegExes used by `PrismJS` to provide syntax highlighting for those languages. You will need to define RegExes for the [tokens](https://prismjs.com/tokens.html). There are a few examples on the official `PrismJS` [website](https://prismjs.com/extending.html).
627+
628+
> [!important]
629+
> The RegExes are stored as strings in the `customPrismLanguages.json` file. This means, that you will have to escape the backslashes. So instead of one backslash (`\`), you'll have to write two (`\\`).
630+
631+
> [!note]
632+
> If the JSON file is malformed or contains invalid RegExes, a notice will be shown when the plugin loads.
633+
634+
A sample `customPrismLanguages.json` which provides syntax highlighting for the `ma3` language would look like this:
635+
636+
```json
637+
{
638+
"ma3": {
639+
"comment": "/(^|[^\\\\#])#.*/gim",
640+
"string": [
641+
{
642+
"pattern": "/'(?:\\\\[\\s\\S]|[^\\\\''])*'/",
643+
"greedy": true
644+
},
645+
{
646+
"pattern": "/\"(?:\\\\[\\s\\S]|[^\\\\\"])*\"/",
647+
"greedy": true
648+
}
649+
],
650+
"number": "/(?:\\b\\d+(?:\\.\\d*)?|\\B\\.\\d+)/gi",
651+
"operator": "/[-+*%]/",
652+
"slashModifier": {
653+
"pattern": "/(\\/\\w+)/",
654+
"alias": "class-name"
655+
},
656+
"macroInputPrompt": {
657+
"pattern": "/\\((?:\\\\[\\s\\S]|[^\\\\(\\\\)])*\\)/",
658+
"alias": "variable",
659+
"greedy": true
660+
},
661+
"macroVariableResolve": {
662+
"pattern": "/\\$.[^\\s]*/",
663+
"alias": "variable",
664+
"greedy": true
665+
},
666+
"keyword": "/\\b(?:\\w+)\\b/"
667+
}
668+
}
669+
```
670+
671+
`ma3` language without custom syntax highlight definition:
672+
![Ma3WithoutCustomPrismLanguageDefitions.png](attachments/Ma3WithoutCustomPrismLanguageDefitions.png)
673+
674+
`ma3` language with custom syntax highlight definition:
675+
![Ma3WithCustomPrismLanguageDefitions.png](attachments/Ma3WithCustomPrismLanguageDefitions.png)
676+
677+
620678
## Bracket Highlight
621679

622680
You can enable bracket highlighting for matching and also for non-matching brackets. If you click next to a bracket (`(,),{,},[,]`), then the bracket itself, and the corresponding opening/closing bracket will be highlighted. You can set individual background, and highlight colors for matching and non-matching brackets:
47.6 KB
Loading
44.6 KB
Loading

main.js

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "codeblock-customizer",
33
"name": "Codeblock Customizer",
4-
"version": "1.4.4",
4+
"version": "1.4.5",
55
"minAppVersion": "0.15.0",
66
"description": "This Obsidian plugin lets you customize your codeblocks in editing, and reading mode as well.",
77
"author": "mugiwara",

0 commit comments

Comments
 (0)