marp-team / marp-core

The core of Marp converter
MIT License
750 stars 127 forks source link

How to create, publish and use a theme? #366

Closed piranna closed 6 months ago

piranna commented 6 months ago

I have read the docs and it's not clear to me. It seems that themes are just CSS files, but you can't use them directly, you need to register them first in marpit with marpit API in Javascript... that's not possible if you are using marp-core or any other higher level module. Also, if it's just only CSS, there's no way to define backgroundImage, ´colororpaginate` by default. Maybe I'm missing something in the docs?

I think it's needed an unified place in the docs showing an example of how to create a theme from scratch, use it locally, and publish it to npm so it can be used as a dependency, like can be done with other similar tools like slidev.

yhatt commented 6 months ago

The basic spec of theme CSS is as described in the documentation of the framework, but how to use the actually created theme is different by downstream tools. Refer to the documentation for the tool you are using (e.g. Marp CLI, Marp for VS Code, and so on).

For development with Marp Core, Marp class is a subclass of Marpit class. Thus, the most of API are exactly same as Marpit (e.g. marp.themeSet.add()). Marp Core avoids redundant explanation for Marpit features.

The theme can express as a simple CSS file, so Marp team does not have uniquely determined how to publish a CSS. Feel free to publish by your own ways. We don't want to lock the theme system into a specific platform like npm because Marp ecosystem have been designed as open-ended. It would narrow the scope of use the ecosystem.