mugiwara85 / CodeblockCustomizer

Codeblock Customizer plugin for Obsidian
MIT License
168 stars 7 forks source link

Since last update: cannot read properties of undefined (reading 'header') #41

Closed merlinuwe closed 1 year ago

merlinuwe commented 1 year ago

Problems with code.

Since the update, I got in some of my notes this error message:

cannot read properties of undefined (reading 'header')

If I deactivate the plugin, everything runs fine.

Windows 10, latest Obsidian, latest CodeblockCustomizer plugin from yesterday.

mugiwara85 commented 1 year ago

Did you remove the data.json file, or reinstalled the plugin as written in the readme?

merlinuwe commented 1 year ago

Thanks for your very fast reply. Yes, after I have read your text in the plugin information. ;-)

(Isn't it possible to delete this file automatically in the update procedure?)

mugiwara85 commented 1 year ago

Is it working now? Not that I know of (which doesn't mean it is not possible, only that I haven't found a way for now.). This file contains the settings, and since I remade the settings (because I messed up a few things) it was required to delete the file. In the future there won't be any issue regarding this.

merlinuwe commented 1 year ago

It does not seem to format the code. (I deactivated my own .css.)

This code

# Hier ist ein einfaches Python-Skript, das die aktuelle Uhrzeit ausgibt:
import datetime
# This is the second comment
now = datetime.datetime.now()
print("Aktuelle Uhrzeit:", now.strftime("%H:%M:%S"))
$attachmentsDirectory = "c:\versuch"
Write-Host "lalala"
#Ausgabe einer Meldung, wenn das Verzeichnis attachments nicht vorhanden ist
Write-Output "INFO: Das Verzeichnis $attachmentsDirectory wurde nicht gefunden."

Shows in edit mode as

image

Shows in view mode as

image

but not similar to

image

This was my former data.json

{
  "bEnableLineNumbers": true,
  "bActiveCodeblockLineHighlight": true,
  "bActiveLineHighlight": true,
  "bGutterHighlight": false,
  "ExcludeLangs": "dataview, ad-*, md",
  "activeCodeBlockLineColor": "#073642",
  "activeLineColor": "#468eeb33",
  "backgroundColor": "#002B36",
  "highlightColor": "#054b5c",
  "bDisplayCodeBlockLanguage": true,
  "bDisplayCodeBlockIcon": true,
  "gutterTextColor": "#6c6c6c",
  "gutterBackgroundColor": "#073642",
  "SelectedTheme": "Dark Theme",
  "header": {
    "bHeaderBold": false,
    "bHeaderItalic": false,
    "bCodeblockLangBold": true,
    "bCodeblockLangItalic": false,
    "bAlwaysDisplayCodeblockLang": false,
    "bAlwaysDisplayCodeblockIcon": true,
    "bDefaultDarkTheme": false,
    "bDefaultLightTheme": false,
    "color": "#0a4554",
    "textColor": "#DADADA",
    "lineColor": "#46cced",
    "codeBlockLangColor": "#000000",
    "codeBlockLangBackgroundColor": "#008080"
  },
  "colorThemes": [
    {
      "name": "Dark Theme",
      "colors": {
        "activeCodeBlockLineColor": "#073642",
        "activeLineColor": "#468eeb33",
        "backgroundColor": "#002B36",
        "highlightColor": "#054b5c",
        "gutterTextColor": "#6c6c6c",
        "gutterBackgroundColor": "#073642",
        "header": {
          "bHeaderBold": false,
          "bHeaderItalic": false,
          "bCodeblockLangBold": true,
          "bCodeblockLangItalic": true,
          "bAlwaysDisplayCodeblockLang": false,
          "bAlwaysDisplayCodeblockIcon": false,
          "bDefaultDarkTheme": true,
          "bDefaultLightTheme": false,
          "color": "#0a4554",
          "textColor": "#DADADA",
          "lineColor": "#46cced",
          "codeBlockLangColor": "#000000",
          "codeBlockLangBackgroundColor": "#008080"
        }
      }
    },
    {
      "name": "Light Theme",
      "colors": {
        "activeCodeBlockLineColor": "#EDE8D6",
        "activeLineColor": "#60460633",
        "backgroundColor": "#FCF6E4",
        "highlightColor": "#E9DFBA",
        "gutterTextColor": "#6c6c6c",
        "gutterBackgroundColor": "#EDE8D6",
        "header": {
          "bHeaderBold": false,
          "bHeaderItalic": false,
          "bCodeblockLangBold": true,
          "bCodeblockLangItalic": true,
          "bAlwaysDisplayCodeblockLang": false,
          "bAlwaysDisplayCodeblockIcon": false,
          "bDefaultDarkTheme": false,
          "bDefaultLightTheme": true,
          "color": "#D5CCB4",
          "textColor": "#866704",
          "lineColor": "#EDD489",
          "codeBlockLangColor": "#C25F30",
          "codeBlockLangBackgroundColor": "#B8B5AA"
        }
      }
    }
  ],
  "alternateColors": [],
  "ThemeName": ""
}
mugiwara85 commented 1 year ago

You have the default Obsidian theme selected. Did you read the readme?

That's how it looks on my machine.

image image

merlinuwe commented 1 year ago

Yes, I use the default theme.

I have activated my css snippet

/* Lösung für den Edit- und den Ansichts-Modus */

.comment  {
display: contents;

}

/* Behebt das Problem mit dem lime Balken im codeblock */
/* Spielt aber in Python itertools.md immer noch verrückt, wenn man die Headline 2 Inhaltsverzeichnis minimiert > */

body > div.app-container > div.horizontal-main-container > div > div.workspace-split.mod-vertical.mod-root > div > div.workspace-tab-container > div > div > div.view-content > div.markdown-reading-view > div > div > div:nth-child(10) > pre > pre  {
    background-color: #0b2b35 !important;

}

/* Code im dark theme 
.theme-dark code  {
    background-color: #002b36 !important;
    font-size: 0.3em;

}
*/

/* Ändert die Schriftgröße von mehrzeiligem Code, der durch ein Plugin beeinflusst wird. */
.theme-dark .codeblock-customizer-RVline-text  {
    font-size: 1.3em;
    color: lightyellow;
    background-color: #073642;  /* teal */
}

.theme-light .codeblock-customizer-RVline-text  {
    font-size: 1.3em;
    color: black;
    background-color: #c3c3c3;  /* hellgrau */
}

and the probleme with the line break is gone.

mugiwara85 commented 1 year ago

The class codeblock-customizer-RVline-text does not exist anymore. But you had the same problem last time as well. You definitely have some conflict with something on your machine.

merlinuwe commented 1 year ago

Now I deactivated the classes codeblock-customizer-RVline-text in my custom css.

I remember ...

When I can format the code like this via your plugin settings, everything is ok? ;-)

image

I named it

image

Can you give me a file with these settings? The colors are much nicer...

image

mugiwara85 commented 1 year ago

They are in the plugin. Select the solarized theme.

image

merlinuwe commented 1 year ago

In the moment, I did it right - it suddenly works ... Thank you very much for your great plugin and the fast help!

image

image

mugiwara85 commented 1 year ago

Anytime :)