jackyzha0 / quartz

🌱 a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites
https://quartz.jzhao.xyz
MIT License
6.77k stars 2.46k forks source link

Obsidian themes integration approach #1451

Open saberzero1 opened 1 day ago

saberzero1 commented 1 day ago

I noticed there have been frequent requests for Obsidian theme support for a long time now.

As mentioned in the Discord server, I had an idea and didn't stop having that idea. The results is Quartz Themes. The project is rather bare bones, but being worked on.

I was wondering if this is something we (eventually) want to integrate in the Quartz repository?

Could be integrated as:

@jackyzha0 @aarnphm what do you guys think? Any idea/opinion/feedback is welcome.

aarnphm commented 1 day ago

I would like to hear from Jacky as well, but we can create a quartz-community where projects like this can live. Collaborators who want to work on these plugins will have more agency to own the plugin instead of waiting to merge into Quartz. This will also make Quartz a lot lighter.

I think it might be worth thinking about plugin system #804 again

but will def involve a bit of design work

aarnphm commented 1 day ago

But then again, it is an opinionated SSG, so plugins might also be a premature optimisation

saberzero1 commented 1 day ago

I would like to hear from Jacky as well, but we can create a quartz-community where projects like this can live. Collaborators who want to work on these plugins will have more agency to own the plugin instead of waiting to merge into Quartz. This will also make Quartz a lot lighter.

I think it might be worth thinking about plugin system #804 again

but will def involve a bit of design work

Apologies for the wall of text...

Fair point. I do think a plugin system within Quartz should be split in two or three components, if we want to pursue that option:

In my opinion, the above three things require three different approaches.

My first thought to implement above would be roughly this:

For Components:

For Processors:

For Styles:

Processors would be the most sophisticated, adding a lot of functionality, but remaining limited to the parsing process. This is similar to a plugin like Dataview, where it adds a lot of functionality when in use inside Obsidian, but is nothing more than a fancy code block in markdown outside of Obsidian.

Components would be like simple plugins, like the calendar plugin in Obsidian. Very self-contained.

Styles would be like themes. Single click install with no options other than the variant/flavor of a theme. Settings are sometimes available with the use of a plugin.

To conclude

saberzero1 commented 1 day ago

I also realize that I might be effectively ushering Quartz v5 into life with above ambitions.

aarnphm commented 20 hours ago

IDK how I feel about the cardinality of components, given that current components/processors/styles are considered in total order.

saberzero1 commented 3 hours ago

IDK how I feel about the cardinality of components, given that current components/processors/styles are considered in total order.

Okay. I have an idea for themes. It is probably easiest if I change my Quartz Themes project to compile the styles to CSS and create a small plugin in Quartz to pull the desired theme into the bundle during the esbuild step. The source repo URL should probably be configurable to allow users to grab additional CSS from other sources, or to specify another theme source beside my project. Something like that at least. Not entirely sure about the specifics yet.

After giving the current plugins ecosystem some more thought, I feel like the current parser system should be turned 90 degrees.

Currently, many parser have one or more of the following:

If feel like we should have 4 parsers instead:

Intuitively, if I place the GitHub parser before the Obsidian parser, I expect the GitHub parser to execute all its operations (text, markdown, HTML, external resources) before the Obsidian parser even starts its text parsing. This is not the case. Currently, all text parsers are run, then markdown, then HTML, then external resources.

I know at least one long-standing bug that currently is caused by this: GitHub style callouts inside markdown codeblocks are parsed by the Obsidian parser as callouts. The GitHub parser runs after Obsidian, but in this specific case, the codeblock part in the GitHub markdown parser should run before the callout part of the Obsidian markdown parser. Currently this is impossible without running all of the GitHub parser before the Obsidian parser.

By turning the parsers like this, it becomes a lot easier to break up parsers into many small parser steps (text to text, markdown to markdown, HTML to HTML, external resources).

A change akin to above would effectively implement a plugin system for the parsing part. There are some small caveats, especially related to the vfile data that is passed on to the filters/emitters, that I'll have to figure out.

Lastly, I feel like the emitters should probably be the place to incorporate default and custom components. I have not given it enough thought yet to give a clear direction. I'll focus on the parsers for now and try out my above idea to see if it holds up. I'll keep you posted.