lilarest9k downloadsAdd your own HTML classes to chosen Markdown elements directly from your notes.
A minimal Obsidian plugin that allows you to add your own HTML
classes to chosen Markdown blocks directly from your notes.
You can add custom classes to :
entire blocks (e.g. a whole list) → By inserting `class: <customClass>` on the line right before it
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
specific elements (e.g. a list item) → By inserting `class: <customClass>` inside of it
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
or even both :
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
ℹ️ For advanced usages and/or informations see the FAQ section.
Here are some ways to use this plugin that may inspire you for your workflows.
Add a class to :
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
|
|
That section displays some example of how people have integrated the Custom Classes plugin in their workflows. Feel free to share yours by opening an issue.
Here the Custom Classes plugin is used to render a Markdown unordered list (ul) as a clean frontmatter block.
→ Source: https://forum.obsidian.md/t/a-frontmatter-that-finally-supports-links-lilas-frontmatter/53087
| This markdown (Edit mode) |
Will be rendered (Live Preview / Read mode) |
||||||
|
|
<div class="my-custom-class"> instead ?
In Obsidian, wrapping a Markdown element in a
divwill break its render in Live Preview and Read modes, and prevent links from being clicked in Edit mode. Also, writing HTML into your notes makes them less readable.Thanks to the Custom Classes plugin you're able to add a custom classes to Markdown elements without breaking anything and using plain-markdown format ! :tada:
Since this plugin is exclusive to Obsidian, the custom classes will not be applied in other editors.
However since the custom classes blocks (
`class: ...`) are simple Markdown inline code-blocks, they will properly render as code blocks in other Markdown editors.
Yes, just separate each class by a comma :
This markdown
(Edit mode)Will be rendered
(Live Preview / Read mode)
`class: first, second, third-one` I'm the paragraph and you ?
<div class="first second third-one"> <p>I'm the paragraph and you ?</p> </div>
Yes the Live Preview mode is fully supported by this plugin.
By the way, elements targetted by a Custom Classes block are rendered in the exact same way in both Read and LP modes, allowing you to write CSS that will work everywhere.
class: prefix is too long, is there any shorthand version ?
Yes the Custom Classes plugin will also consider as custom classes block every inline code-block that starts with
cls:or with.So
`cls: wow`and`.wow`are equivalent to`class: wow`.
This plugin is originally inspired by the Obsidian Stylist plugin but has been entirely rewritten to :
See CONTRIBUTING.md.