secure-77 / Perlite

A web-based markdown viewer optimized for Obsidian
https://perlite.secure77.de/
MIT License
968 stars 81 forks source link

Work with Custom CSS from Themes #98

Closed Nargath closed 11 months ago

Nargath commented 12 months ago

Is your feature request related to a problem? Please describe. When using a theme that has custom css snippets embedded in the theme's code, those aren't rendering, or working as intended on the Perlite hosted site. For example, I'm building a info repository using the ITS theme (https://github.com/SlRvb/Obsidian--ITS-Theme), which has a slew of custom CSS in it that enhances what the core callouts are and can do. Introduces wiki-style infoboxes, collapsible callouts, being able to manipulate the look and make up of callouts. But these only render the basic Obsidian callouts, and most of the time jumble the page.

Describe the solution you'd like To see Perlite be able to handle custom css snippets that may be embedded in other Theme's direct code.

Additional context Add any other context or screenshots about the feature request here.

First screenshot is the callouts working correctly in Obsidian. The infobox on the right hand side, and the coloured and bordered boxes are new types of callouts, as well as being marked as collapsible, and having the icon removed as part of the code. ITS Callouts Example - Obsidian

This is that exact same page as rendered in Perlite, noting that the infobox on the right is now inside a standard callout, and the collapsible callouts underneath are fully expanded and don't even have the option for collapsing. ITS Callouts Example - Perlite

Nargath commented 12 months ago

I've had a small break through with this.

It isn't that the css snippets themselves aren't working; its the attributes that are associated with the custom css code.

Callouts are adjustable via attributes within the initial callout code (https://publish.obsidian.md/slrvb-docs/ITS+Theme/Callout+Adjustments). They are separated from the main callout component by a pipe | So a normal "metadata" callout is: [!metadata]

To have a collapsible metadata callout needs to be: [!metadata]+

And to have a metadata callout with the title, or the title icon needs to be: [!metadata|no-t no-i]

When I have callouts with attributes in Perlite, it breaks them rendering as the custom callouts, and reverts them back to Obsidian internal callouts, namely the default Info one.

Here's a screenshot of Perlite with a infobox and metadata callout without attributes, and then a metadata with attributes underneath the line image

secure-77 commented 11 months ago

I can see the problem but to implement different html structures or obsidian tag handles based on theme seems very complex and a never ending story. I didn't`t think I can take care about this. Its already a lot of work to handle the default obsidian functionalities. So best what you can do is to fork the project and adjust it by yourself I guess...

Nargath commented 11 months ago

Yeah, I figured it might be well beyond scope of the app, but figured it didn't hurt to bring it up!

And I'd fork it and make the changes myself, but honestly I'd be so completely lost, I wouldn't even know where to start :P