Skip to content

Commit 1b05b05

Browse files
committed
Release 1.4.1
1 parent 972e3a7 commit 1b05b05

File tree

10 files changed

+121
-93
lines changed

10 files changed

+121
-93
lines changed

Changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
- 1.4.1 (2026.03.11)
2+
New:
3+
- Added option to use PrismJS for syntax highlighting in editor mode. This means more languages get syntax highlight and same syntax highlight between editor and reading mode (#82,#134,#140)
4+
15
- 1.4.0 (2026.03.10)
26
New:
37
- Wrap code now also works in editor mode

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The plugin lets you customize the code blocks in the following way:
2222
- Transform code comments into styled annotations.
2323
- Apply syntax highlighting to inline code.
2424
- Hide fence lines in editor mode for a cleaner look.
25+
- **NEW:** Added option to use PrismJS for syntax highlighting in editor mode => Same syntax highlight in editor and reading mode and more langauges get syntax highlighted
2526
- **NEW:** Search option in the settings page to find faster a specific setting
2627
- **NEW:** Wrap/Unwrap button in editor mode
2728
- **NEW:** Execute Code Plugin compatibility
@@ -39,6 +40,7 @@ For a more detailed list of changes, check the [Changelog](./Changelog.txt).
3940
## 📋 Table of Contents
4041

4142
- [Parameters](#parameters)
43+
- [PrismJS Syntax Highlighting](#prismjs-syntax-highlighting)
4244
- [Themes](#themes)
4345
- [Display Filename/Title](#display-filenametitle)
4446
- [Header](#header)
@@ -118,6 +120,27 @@ All parameters can be defined using `:` or `=`.
118120

119121
</details>
120122

123+
## PrismJS Syntax Highlighting
124+
125+
This is an **experimental** setting, but it is worth talking about this.
126+
127+
Small background information:
128+
The syntax highlighting wasn't the same in editing and reading mode, because Obsidian uses two different engines. The one used in editor mode is `CodeMirror 6`, and the other for reading mode is `PrismJS`. The problem with this is, that `CodeMirror` supports less languages then `PrismJS`, and even if it supports the same language it will probably still differ, because it works different.
129+
130+
So what does this setting do? It forces the editor to use `PrismJS` in editor mode. This results, that when this setting is enabled, the syntax highlighting is the **same** in editing and reading modes!
131+
But that's not all! This setting also has a positive side effect. `CodeMirror` does support a lot of languages, but nearly not as many as `PrismJS`. When this setting is enabled, that also means that languages which `CodeMirror` does not support (e.g. `graphql` or `makefile` or `hlsl`) also get syntax highlighting, because `PrismJS` does support it.
132+
133+
Even though this setting is not as thourughly tested as others, I wanted to release it easlier. Should you encounter some errors or bugs, just open an issue.
134+
135+
Example code block in editor mode with the setting disabled:
136+
137+
![PrismDisabled](attachments/PrismDisabled.png)
138+
139+
Same code block with setting enabled (matches reading mode):
140+
141+
![PrismEnabled](attachments/PrismEnabled.png)
142+
143+
121144
## Themes
122145

123146
The plugin comes with multiple themes (Obsidian, Solarized, Dracula, Gruvbox, Nord, Tokyo Night). The default theme is Obsidian.

attachments/PrismDisabled.png

31.6 KB
Loading

attachments/PrismEnabled.png

32.7 KB
Loading

main.js

Lines changed: 74 additions & 74 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.0",
4+
"version": "1.4.1",
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",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeblock-customizer",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "The plugin lets you customize your Obsidian code blocks and inline code in editing mode and reading mode as well.",
55
"main": "main.js",
66
"scripts": {

src/SettingsTab/Appearance.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ export class AppearanceSettings {
3636
const editorActiveLineSetting = createPickrSetting(appearanceDiv, 'Editor active line color', '', "editorActiveLineColor", this.pickerInstances, this.plugin);
3737
editorActiveLineSetting.settingEl.toggleClass('codeblock-customizer-setting-hidden', !this.plugin.settings.pluginSettings.enableEditorActiveLineHighlight);
3838

39+
const prismSetting = new Setting(appearanceDiv)
40+
.setName('Use PrismJS syntax highlighting in editor mode')
41+
.setDesc('If enabled, editor mode will use PrismJS for syntax highlighting instead of CodeMirror\'s built-in highlighting. This makes editor mode syntax highlighting match reading mode syntax highlighting.')
42+
.addToggle(toggle => toggle
43+
.setValue(this.plugin.settings.pluginSettings.codeblock.usePrismHighlight)
44+
.onChange(async (value) => {
45+
this.plugin.settings.pluginSettings.codeblock.usePrismHighlight = value;
46+
await this.plugin.saveSettings();
47+
})
48+
);
49+
const warningEl = prismSetting.descEl.createDiv({ cls: "mod-warning" });
50+
warningEl.style.color = "var(--text-error)";
51+
warningEl.style.marginTop = "4px";
52+
warningEl.style.fontWeight = "bold";
53+
warningEl.setText("Experimental: This feature is still being tested. Please report any issues you encounter.");
54+
3955
// code block styling
4056
const codeBlockDetails = createDetailsGroup(appearanceDiv, 'Code Block Styling', 'codeBlockDetailsOpen', this, this.getSearchQuery);
4157

src/SettingsTab/Behavior.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,6 @@ export class BehaviorSettings {
5757
})
5858
);
5959

60-
const prismSetting = new Setting(behaviorDiv)
61-
.setName('Use PrismJS syntax highlighting in editor mode')
62-
.setDesc('If enabled, editor mode will use PrismJS for syntax highlighting instead of CodeMirror\'s built-in highlighting. This makes editor mode syntax highlighting match reading mode syntax highlighting.')
63-
.addToggle(toggle => toggle
64-
.setValue(this.plugin.settings.pluginSettings.codeblock.usePrismHighlight)
65-
.onChange(async (value) => {
66-
this.plugin.settings.pluginSettings.codeblock.usePrismHighlight = value;
67-
await this.plugin.saveSettings();
68-
})
69-
);
70-
const warningEl = prismSetting.descEl.createDiv({ cls: "mod-warning" });
71-
warningEl.style.color = "var(--text-error)";
72-
warningEl.style.marginTop = "4px";
73-
warningEl.style.fontWeight = "bold";
74-
warningEl.setText("Experimental: This feature is still being tested. Please report any issues you encounter.");
75-
7660
// grouped code blocks
7761
const groupedCodeBlocksDetails = createDetailsGroup(behaviorDiv, 'Grouped Code Block Settings', 'groupedCodeBlocksDetailsOpen', this, this.getSearchQuery);
7862

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"1.2.8": "0.15.0",
1111
"1.3.0": "0.15.0",
1212
"1.3.1": "0.15.0",
13-
"1.4.0": "0.15.0"
13+
"1.4.0": "0.15.0",
14+
"1.4.1": "0.15.0"
1415
}

0 commit comments

Comments
 (0)