Skip to content

Syntax highlighting inconsistent between inline code and code blocks #168

@notthepenguins

Description

@notthepenguins

Overview

Platform: Android 16, Obsidian 1.12.7 (303)
Issue: The syntax highlighting settings between inline code and code blocks are not applied consistently.
Details: The syntax highlighting colors for inline code are both displayed inconsistently and controlled by different features. Additionally, the syntax highlighting sometimes changes on clicking on the line of code, and does not change until restarting the application in edit mode. I'd put this in as a separate issue but it seems to be related.

Reproduction

Markdown in all examples:

`{rust} // comment`
`{rust} "string"`
`{rust} fn some_function(){};`

```rust
// comment

"string"

fn some_function(){};
```

All community plugins aside from Codeblock Customizer disabled. All CSS snippets disabled. Obsidian base theme set to default (dark)

Issue pt. 1 (Inconsistent Highlighting in Edit mode)

Example 1 (Same themes)

Codeblock Customizer Theme: Dracula
Codeblock Customizer Global Syntax Theme: Dracula Syntax

Resulting highlighting:

DetailsImage

Example 2 (Different themes)

Codeblock Customizer Theme: Gruvbox
Codeblock Customizer Global Syntax Theme: Dracula Syntax

Resulting highlighting:

DetailsImage

Example 3: (Different themes)

Codeblock Customizer Theme: Gruvbox
Codeblock Customizer Global Syntax Theme: Monokai

Resulting highlighting:

DetailsImage

Example 4: (Theme and no theme)

Codeblock Customizer Theme: Solarized
Codeblock Customizer Global Syntax Theme: (None)

Resulting highlighting:

DetailsImage

Issue pt. 2: Syntax highlighting changing mid-session

Codeblock Customizer theme: Nord
Codeblock Customizer Global Syntax Theme: (None)

Images being referenced:

A (Edit, inconsistent highlighting):

DetailsImage

B (Edit, consistent highlighting):
DetailsImage

C (Edit + Source, inconsistent highlighting):
DetailsImage

D (Edit + Source, consistent highlighting):
DetailsImage

E (Preview, consistent highlighting):
DetailsImage

Example 1 (Edit -> Preview -> Edit):

  • On starting in Edit mode: A (Edit, inconsistent highlighting):
  • On switching to Preview mode: E (Preview, consistent highlighting)
  • On switching back to Edit mode: A (Edit, inconsistent highlighting)

Example 2 (Edit -> Edit (Source) -> Edit):

  • On starting in Edit mode: A (Edit, inconsistent highlighting):
  • On switching to Edit (Source) mode: D (Edit + Source, consistent highlighting)
  • On switching back to Edit mode: B (Edit, consistent highlighting)

Example 3 (Edit (Source) -> Preview -> Edit (Source) -> Edit (No Source)

  • On starting in Edit (Source) mode: C (Edit + Source, inconsistent highlighting)
  • On switching to Preview mode: E (Preview, consistent highlighting)
  • On switching back to Edit (Source) mode: C (Edit + Source, inconsistent highlighting)
  • On switching to Edit (No Source) mode: B (Edit, consistent highlighting)

Example 4 (Preview -> Edit (Source)):

  • On starting in Preview mode: E (Preview, consistent highlighting)
  • On switching to Edit (Source) mode: D (Edit + Source, consistent highlighting)

Example 5 (Preview -> Edit):

  • On starting in Preview mode: E (Preview, consistent highlighting)
  • On switching to Edit mode: B (Edit, consistent highlighting)

Example 6 (Edit -> Click):

  • On starting in Edit mode: A (Edit, inconsistent highlighting):
  • On clicking in any code block: B (Edit, consistent highlighting)

Example 7 (Edit (Source) -> Click):

  • On starting in Edit (Source) mode: C (Edit + Source, inconsistent highlighting)
  • On clicking in any code block: D (Edit + Source, consistent highlighting)

Flowchart Version

flowchart LR
    subgraph st [Start]
    A{{"Start in..."}}
    end

    subgraph ed [Edit]
    A-->|"Edit"|G(["Inconsistent Highlighting"])
    G-->H{{"Change to Edit (Source)"}}
    G-->N{{"Change to Preview"}}-->O(["Consistent Highlighting"])-->P{{"Change to Edit"}}-->G
    G-->T{{"Click in any code block"}}
    end
    
    subgraph eds [Edit Source]
    A-->|"Edit (source)"|I(["Inconsistent Highlighting"])
    I-->J{{"Change to Preview"}}-->K(["Consistent Highlighting"])-->L{{"Change to Edit (Source)"}}-->I
    I-->Q{{"Change to Edit"}}
    I-->U{{"Click in any code block"}}
    end
    
    subgraph pv [Preview]
    A-->|"Preview"|R(["Consistent Highlighting"])
    R-->S{{"Change to Edit/Edit (Source)"}}
    end

    subgraph so [Stable Output]
    S-->D(["Consistent Highlighting"])
    H-->D
    Q-->D
    T-->D
    U-->D
    D-->E{{"Change to Edit"}}-->D
    D-->F{{"Change to Edit (Source)"}}-->D
    D-->M{{"Change to Preview"}}-->D
    end

    st~~~ed
    st~~~eds
    st~~~pv
    ed~~~so
    eds~~~so
    pv~~~so
Loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions