SHARE
TWEET

TOC Autonumbering for Typora

a guest Nov 6th, 2016 337 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**************************************
  2.  * Header Counters in TOC
  3.  **************************************/
  4.  
  5. /* No link underlines in TOC */
  6. .md-toc-inner {
  7.     text-decoration: none;
  8. }
  9.  
  10. .md-toc-content {
  11.     counter-reset: h1toc
  12. }
  13.  
  14. .md-toc-h1 {
  15.     margin-left: 0;
  16.     font-size: 1.5rem;
  17.     counter-reset: h2toc
  18. }
  19.  
  20. .md-toc-h2 {
  21.     font-size: 1.1rem;
  22.     margin-left: 2rem;
  23.     counter-reset: h3toc
  24. }
  25.  
  26. .md-toc-h3 {
  27.     margin-left: 3rem;
  28.     font-size: .9rem;
  29.     counter-reset: h4toc
  30. }
  31.  
  32. .md-toc-h4 {
  33.     margin-left: 4rem;
  34.     font-size: .85rem;
  35.     counter-reset: h5toc
  36. }
  37.  
  38. .md-toc-h5 {
  39.     margin-left: 5rem;
  40.     font-size: .8rem;
  41.     counter-reset: h6toc
  42. }
  43.  
  44. .md-toc-h6 {
  45.     margin-left: 6rem;
  46.     font-size: .75rem;
  47. }
  48.  
  49. .md-toc-h1:before {
  50.     color: black;
  51.     counter-increment: h1toc;
  52.     content: counter(h1toc) ". "
  53. }
  54.  
  55. .md-toc-h1 .md-toc-inner {
  56.     margin-left: 0;
  57. }
  58.  
  59. .md-toc-h2:before {
  60.     color: black;
  61.     counter-increment: h2toc;
  62.     content: counter(h1toc) ". " counter(h2toc) ". "
  63. }
  64.  
  65. .md-toc-h2 .md-toc-inner {
  66.     margin-left: 0;
  67. }
  68.  
  69. .md-toc-h3:before {
  70.     color: black;
  71.     counter-increment: h3toc;
  72.     content: counter(h1toc) ". " counter(h2toc) ". " counter(h3toc) ". "
  73. }
  74.  
  75. .md-toc-h3 .md-toc-inner {
  76.     margin-left: 0;
  77. }
  78.  
  79. .md-toc-h4:before {
  80.     color: black;
  81.     counter-increment: h4toc;
  82.     content: counter(h1toc) ". " counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". "
  83. }
  84.  
  85. .md-toc-h4 .md-toc-inner {
  86.     margin-left: 0;
  87. }
  88.  
  89. .md-toc-h5:before {
  90.     color: black;
  91.     counter-increment: h5toc;
  92.     content: counter(h1toc) ". " counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". "
  93. }
  94.  
  95. .md-toc-h5 .md-toc-inner {
  96.     margin-left: 0;
  97. }
  98.  
  99. .md-toc-h6:before {
  100.     color: black;
  101.     counter-increment: h6toc;
  102.     content: counter(h1toc) ". " counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". " counter(h6toc) ". "
  103. }
  104.  
  105. .md-toc-h6 .md-toc-inner {
  106.     margin-left: 0;
  107. }
  108.  
  109. /**************************************
  110.  * Header Counters in Content
  111.  **************************************/
  112.  
  113. /** initialize css counter */
  114. #write {
  115.     counter-reset: h1
  116. }
  117.  
  118. h1 {
  119.     counter-reset: h2
  120. }
  121.  
  122. h2 {
  123.     counter-reset: h3
  124. }
  125.  
  126. h3 {
  127.     counter-reset: h4
  128. }
  129.  
  130. h4 {
  131.     counter-reset: h5
  132. }
  133.  
  134. h5 {
  135.     counter-reset: h6
  136. }
  137.  
  138. /** put counter result into headings */
  139. #write h1:before {
  140.     counter-increment: h1;
  141.     content: counter(h1) ". "
  142. }
  143.  
  144. #write h2:before {
  145.     counter-increment: h2;
  146.     content: counter(h1) "." counter(h2) ". "
  147. }
  148.  
  149. #write h3:before, h3.md-focus.md-heading:before { /*override the default style for focused headings */
  150.     counter-increment: h3;
  151.     content: counter(h1) "." counter(h2) "." counter(h3) ". "
  152. }
  153.  
  154. #write h4:before, h4.md-focus.md-heading:before {
  155.     counter-increment: h4;
  156.     content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) ". "
  157. }
  158.  
  159. #write h5:before, h5.md-focus.md-heading:before {
  160.     counter-increment: h5;
  161.     content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "
  162. }
  163.  
  164. #write h6:before, h6.md-focus.md-heading:before {
  165.     counter-increment: h6;
  166.     content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". "
  167. }
  168.  
  169. /** override the default style for focused headings */
  170. #write>h3.md-focus:before, #write>h4.md-focus:before, #write>h5.md-focus:before, #write>h6.md-focus:before, h3.md-focus:before, h4.md-focus:before, h5.md-focus:before, h6.md-focus:before {
  171.     color: inherit;
  172.     border: inherit;
  173.     border-radius: inherit;
  174.     position: inherit;
  175.     left: initial;
  176.     float: none;
  177.     top: initial;
  178.     font-size: inherit;
  179.     padding-left: inherit;
  180.     padding-right: inherit;
  181.     vertical-align: inherit;
  182.     font-weight: inherit;
  183.     line-height: inherit;
  184. }
RAW Paste Data
Want to get better at CSS?
Learn to code CSS in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top