Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Add own classes in markdown/html tags?

Started by Muut Archive 10 years ago · 4 replies · 2986 views
10 years ago

Is it possible to add own classes in h1–h6 and p tags with yaml? Example:

TXT
# This is main heading to be processed with magic

And I would like to have all h1 tags adapted with custom class "main-heading" -> output in html

HTML
<h1 class="main-heading">This is main heading to be processed with magic</h1>

Maybe something like this in yaml:

YAML

process:
  content:
    classes:
      h1: main-heading
---
10 years ago

in .md's header

YAML
classes:
   - h1: main-heading
   - h2: secondary-heading

in your TWIG template:

TWIG

<h1 class="{{ header.classes.h1 }} ">This is main heading to be processed with magic</h1>
<h2 class="{{ header.classes.h2 }} ">This is secondary heading to be processed with magic</h2>
---
10 years ago

So, I can not use {{ content }} in TWIG template and get the classes automatically, if there is headings used?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1357 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago