obsidian-custom-classes icon indicating copy to clipboard operation
obsidian-custom-classes copied to clipboard

Still renders in source mode

Open ggstrader opened this issue 2 years ago • 14 comments

Describe the bug Rendering should be reserved for Live Preview and Reader View only, but blocks with custom classes are still rendered in Source view.

Expected behavior Should be able to (in Source view) see and edit each inline code block as if it were a plain-text editor like notepad.

ggstrader avatar Feb 28 '23 02:02 ggstrader

@ggstrader Are you using the latest version of the plugin (2.6.1) ? I'll investigate this later in the day

LilaRest avatar Feb 28 '23 08:02 LilaRest

Re @ggstrader.

I've not been able to reproduce this bug. Very old version of the plugin may cause that, please ensure you're using the latest one.

If you already are, please provide me with your Obsidian app's version and a note content with which you are observing this bug.

LilaRest avatar Feb 28 '23 10:02 LilaRest

I'm using 2.6.1 and Obsidian 1.1.15, Windows 10. I just assumed based on the element view that the plugin wasn't respecting source mode. But, now I've "figured it out." Except I have absolutely no idea what's going on.

I couldn't reproduce it in Sandbox. So I copied the entire vault to another directory, and still had the issue. Turned off all the plugins, still had the issue. Removed all other plugins and snippets. Still had the issue. By process of elimination, found that removing one file - /software/obsidian/plugins/Plugin Notes.md - made the problem go away??? However, re-copying the vault and removing only that file doesn't fix the problem. Re-copying and removing everything except that file doesn't fix the problem. Only if I delete 90% of my vault (including that file), and undo that delete, does the problem go away. I.e. if absolutely nothing changes (except maybe file metadata) for most of my files including that strange problem file, somehow it's fixed. This is bonkers.

Anyways, it appears(?) to have nothing to do with the plugin? Somehow it's OS related? I'm genuinely confused.

ggstrader avatar Feb 28 '23 23:02 ggstrader

Figured it out! The issue resurfaced and I 'bout died.

It had nothing to do with any of that.

It looks like the "first" pane dictates what mode other panes are in. This is reproducible in the Sandbox.

  1. Open a note with a custom class in source mode
  2. Open another note in a separate pane
  3. Observe that toggling between Live/Source mode has no effect in the second pane
  4. Switch the first pane to Live
  5. Observe when clicking in the second pane that it switches modes
  6. Toggling the mode in the second pane again has no effect

ggstrader avatar Mar 01 '23 06:03 ggstrader

@ggstrader Thanks for this investigation ! I'll try to fix that later in the day :)

LilaRest avatar Mar 01 '23 10:03 LilaRest

I had the same issue as ggstrader also another issue that might be caused by this. I can't paste from clipboard if the item has backtics as the first line, disabling the plugin fixes it.

`class:meta`
- creation:: 2023-01-21T18:55:12
- author:: [[John Doe]]
- parents:: [[Note]], [[Another note]]
- status:: #MayBePartial

Also, in source view it renders as if I'm in live preview and hides "class:meta" but shows if I click inside the fields.

Outside that I'm having no issues, I love your plugin and so happy I have a way to link my notes in fields, thank you!

AzulaBeLovely avatar Mar 04 '23 03:03 AzulaBeLovely

@ggstrader @AzulaBeKinky I hadn't added this to my tasks list and had totally forgotten to investigate this issue 🤭

I'll let you know when I'll have more infos or when it's fixed.

Happy to read that this plugin is useful to you @ @AzulaBeKinky 😊

LilaRest avatar Mar 04 '23 08:03 LilaRest

I had the same issue! On Win10

YIRU69 avatar Mar 06 '23 07:03 YIRU69

I'm not sure if this is related but, aside from having the same problem as above with rendering even in source mode, the class doesn't seem to be applied at all and instead I get a code block.

I have the Copy Document As HTML plugin and when I copy the HTML, the apparent output is like this:

<div><h2 data-heading="`class:meta`"><code>class:meta</code></h2>
<ul>
<li>List 2</li>
<li>List 3</li>
</ul></div>

As you can see, the backticks are causing it to be wrapped in a code block and not get rendered at all. For some reason the first list item is also getting cut off (there actually was a "List 1" item)

I've tried disabling all plugins and any relevant settings I can think of. It may be I'm doing something wrong since I'm new to Obsidian.

ThornedRose avatar Apr 02 '23 05:04 ThornedRose

@ThornedRose Are you using it for the Lila's frontmatter ? I'll soon release a new version of this one on the Obsidian forum that doesn't rely on this plugin to work.

I'm actually not using this plugin myself anymore, I don't plan to continue maintaining it in the future, but would be happy to accept any PR.

LilaRest avatar Apr 02 '23 08:04 LilaRest

@ThornedRose Are you using it for the Lila's frontmatter ? I'll soon release a new version of this one on the Obsidian forum that doesn't rely on this plugin to work.

I'm actually not using this plugin myself anymore, I don't plan to continue maintaining it in the future, but would be happy to accept any PR.

I do not use it for front matter. Just for trying to style individual elements. A problem I've been beating my head against with immense frustration for two solid days :(

My use case is that I have a heap of books, each one as a note. At the top of each book, I have a table containing a summary of the characters in the book, the period in which it takes place, organisations and places of significance, etc. It looks similar to the metadata of the book but is just more flexible (it also has dataview inline fields). I wanted to be able to style it differently from other tables so it stands out more. My work around so far has been to put it in a callout. But that also has it's own limitations since I now can't put any other tables in the book notes callouts otherwise they'll get styled the same.

It would be wonderful if Obsidian either added a unique identifier to each element by default or at least allowed optionally adding identifiers and classes such as your plugin provides.

Unfortunately my forte lies solely in HTML and CSS and I have Cognitive Impairment so as much as I would love to be able to contribute to this wonderful plugin, I don't have the knowledge or ability. :(

ThornedRose avatar Apr 03 '23 21:04 ThornedRose

@ThornedRose Oh I see ! Thanks for those details :)

If I understood your problem correctly, I think callout could indeed be the solution. Do you know that you can style callouts from their identifiers ?

I've myself replaced the usage of this plugin for my frontmatter with a callout. Here is a minimal example that might inspire you.

Here is the callout in my note :

>[!meta]-
> type:: XP
> creation:: 2023-03-31T23:44
> archived:: false

And now the callout is accessible using the [data-callout="meta"] CSS selector, so I can change its background like this :

[data-callout="meta"] {
    background: red;
}

LilaRest avatar Apr 03 '23 21:04 LilaRest

And now the callout is accessible using the [data-callout="meta"]

OMG, game changer!!! Somehow I missed that. Probably not surprising after staring at html for days on end. 😅

Coupled with the Metatable plugin, I now have wonderful control over custom meta content. Thanks so much!!

ThornedRose avatar Apr 03 '23 23:04 ThornedRose

@ThornedRose Glad it helped ! :blush:

LilaRest avatar Apr 04 '23 00:04 LilaRest