LoginSignup
2
0

マークダウンの見出しに連番を入れる_プリザンターにて

Posted at

プリザンターでは[md]を使えば内容がマークダウンで記載できます。
その時に連番のためのスタイルを設定したかったので試してみました。

見出しに連番を入れるCSS

こちらの記事のをそのまま使わせて貰いました。
この内容をスタイルに設定して、「新規作成」「編集」にチェック。
https://qiita.com/itagakishintaro/items/437418f917cc31de10cd

そのままスタイルに入れただけではおかしくなった。
上のPleasanterの所に「0-1.」とでる!
内容の連番が「2.」から始まっている!
前.png
なぜ?。。。。
と思ったけど、このページ全体の見出しに対してのスタイルになるから、そらそうだ。。。

「内容」部分にだけ適用されるよに見直し

「内容」の部分は、<div class"md">となっているのでそのように、.mdを追加するように変更する。

これで「内容」部分だけに適用できた!!

スタイル.css
.md {
    counter-reset: chapter;
}
.md h1 {
    counter-reset: sub-chapter;
}
.md h2 {
    counter-reset: section;
}

.md h1::before {
    counter-increment: chapter;
    content: counter(chapter) ". ";
}
.md h2::before {
    counter-increment: sub-chapter;
    content: counter(chapter) "-" counter(sub-chapter) ". ";
}
.md h3::before {
    counter-increment: section;
    content: counter(chapter) "-" counter(sub-chapter) ".-" counter(section) ".";
}

.md h1, .md h2, .md h3 { 
    border-bottom: 5px solid #7db4e6;
}

後.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0