Typora code block color matching and title serial number implementation code

Typora code block color matching and title serial number implementation code

Effect: The title has its own serial number, the code block has a color scheme, and a Mac-like icon appears in the upper left corner of the code block

insert image description here

First open the theme folder

File > Preferences > Appearance > Open Theme Folder

Then edit the base.user.css file (if it doesn't exist, create a new one)

Just add the following code

/*Title automatically adds serial number*/
.sidebar-content {
    counter-reset:h1
}

.outline-h1 {
    counter-reset:h2
}

.outline-h2 {
    counter-reset: h3
}

.outline-h3 {
    counter-reset:h4
}

.outline-h4 {
    counter-reset: h5
}

.outline-h5 {
    counter-reset: h6
}

.outline-h1>.outline-item>.outline-label:before {
    counter-increment: h1;
    content: counter(h1) " "
}

.outline-h2>.outline-item>.outline-label:before {
    counter-increment: h2;
    content: counter(h1) "."counter(h2) " "
}

.outline-h3>.outline-item>.outline-label:before {
    counter-increment: h3;
    content: counter(h1) "."counter(h2) "."counter(h3) " "
}

.outline-h4>.outline-item>.outline-label:before {
    counter-increment: h4;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) " "
}

.outline-h5>.outline-item>.outline-label:before {
    counter-increment: h5;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) " "
}

.outline-h6>.outline-item>.outline-label:before {
    counter-increment: h6;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) "."counter(h6) " "
}

#write {
    counter-reset:h1
}

h1 {
    counter-reset:h2
}

h2 {
    counter-reset: h3
}

h3 {
    counter-reset:h4
}

h4 {
    counter-reset: h5
}

h5 {
    counter-reset: h6
}

#write h1:before {
    counter-increment: h1;
    content: counter(h1) " "
}

#write h2:before {
    counter-increment: h2;
    content: counter(h1) "."counter(h2) " "
}

#write h3:before,
h3.md-focus.md-heading:before

    {
    counter-increment: h3;
    content: counter(h1) "."counter(h2) "."counter(h3) " "
}

#write h4:before,
h4.md-focus.md-heading:before {
    counter-increment: h4;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) " "
}

#write h5:before,
h5.md-focus.md-heading:before {
    counter-increment: h5;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) " "
}

#write h6:before,
h6.md-focus.md-heading:before {
    counter-increment: h6;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) "."counter(h6) " "
}

#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 {
    color: inherit;
    border: inherit;
    border-radius: inherit;
    position: inherit;
    left: initial;
    float: none;
    top: initial;
    font-size: inherit;
    padding-left: inherit;
    padding-right: inherit;
    vertical-align: inherit;
    font-weight: inherit;
    line-height: inherit;
}
/*Because the code blocks of different themes are different, the code part is unified*/
.CodeMirror-lines {
    padding-left: 4px;
}

.code-tooltip {
    box-shadow: 0 1px 1px 0 rgba(0,28,36,.3);
    border-top: 1px solid #eef2f2;
}

.md-fences,
code,
tt {
    background-color: #f8f8f8;
    border-radius: 3px;
    padding: 0;
    padding-left: 4px !important;
    padding-right: 4px !important;
    font-size: 0.9em;
}

code {
    background-color: #f3f4f4;
    padding: 0 2px 0 2px;
}

.md-fences {
    margin-bottom: 15px;
    margin-top: 15px;
    padding-top: 8px;
    padding-bottom: 6px;
}


.md-task-list-item > input {
  margin-left: -1.3em;
}

@media print {
    html {
        font-size: 13px;
    }
    table,
    pre {
        page-break-inside: avoid;
    }
    pre {
        word-wrap: break-word;
    }
}

.md-fences {
	background-color: #f8f8f8;
}
#write pre.md-meta-block {
	padding: 1rem;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f7f7f7;
    border: 0;
    border-radius: 3px;
    color: #777777;
    margin-top: 0 !important;
}

.mathjax-block>.code-tooltip {
	bottom: .375rem;
}



/*Dark background*/

#write .md-fences:not([mermaid-type]) {
    padding-top: 7px;
    border-radius: 10px;
    background-color: #282c34;
    color: #eeeeee;
}

.code-tooltip .ty-input,
.code-tooltip input {
    color: #eee;
}


/*Three icons of MAC*/
.CodeMirror-wrap .CodeMirror-scroll {
    padding-top: 20px;
}

#write .md-fences:before {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 13px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    float: left;
    background-color: #fa3534;
}

#write .CodeMirror-scroll:before {
    content: "";
    display: block;
    position: absolute;
    top: 0px;
    left: 29px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    float: left;
    z-index: 999;
    background-color: #ff9900;
}
#write .md-fences::after {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 53px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    float: left;
    background-color: #19be6b;
}

/*Color*/
.CodeMirror-line .cm-number,/*number*/
.CodeMirror-line .cm-property {/*The method called*/
    color: #f08d49;
}
.CodeMirror-line .cm-variable-3,/*parameter, type*/
.CodeMirror-line .cm-qualifier,/*css class*/
.CodeMirror-line .cm-variable-2 {/*Parameters used*/
    color: #FFCB6B;
}
.CodeMirror-line .cm-meta,/*Ellipses, comments, etc.*/
.CodeMirror-line .cm-atom,/*css attribute value, Boolean value, etc.*/
.CodeMirror-line .cm-keyword{/*keyword*/
    color: #cc99cd;
}
.CodeMirror-line .cm-def,/*variable name*/
.CodeMirror-line .cm-variable {/*The variable name used*/
    color: #FFCB6B;
}
.CodeMirror-line .cm-builtin {/*The attribute to be called*/
    color: #82AAFF;
}
.CodeMirror-line .cm-comment {/*Comment*/
    color: #888;
}
.CodeMirror-line .cm-string,/*string*/
.CodeMirror-line .cm-string-2 {/*Regular expression*/
    color: #7ec699
}
.CodeMirror-line .cm-operator {/*operator*/
    color: #67cdcc
}
.CodeMirror div.CodeMirror-cursor {/* cursor */
    border-left: 1px solid #fff;
    z-index: 3;
}
.CodeMirror-selected,/*Selected background*/
.CodeMirror-selectedtext {
    background: #666 !important;
}

/*html*/
.CodeMirror-line .cm-tag{/*Tag name*/
    color: #F07178;
}
.CodeMirror-line .cm-bracket{/*Tag angle bracket*/
    color: #FFF;
}
.CodeMirror-line .cm-attribute{/*attribute*/
    color: #FFCB6B;
}

This is the end of this article about the implementation code of Typora code block color matching and title serial number. For more relevant Typora code block content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  Seven ways to implement array deduplication in JS

>>:  SQL Practice Exercise: Online Mall Database Product Category Data Operation

Recommend

Docker /var/lib/docker/aufs/mnt directory cleaning method

The company's service uses docker, and the di...

Echarts legend component properties and source code

The legend component is a commonly used component...

Detailed explanation of slave_exec_mode parameter in MySQL

Today I accidentally saw the parameter slave_exec...

vite2.x implements on-demand loading of ant-design-vue@next components

1. Use version vite:2.0 ant-design-vue: 2.0.0-rc....

Elegant practical record of introducing iconfont icon library into vue

Table of contents Preface Generate SVG Introducti...

Detailed steps for deploying Tomcat server based on IDEA

Table of contents Introduction Step 1 Step 2: Cre...

Detailed View of Hidden Columns in MySQL

Table of contents 1. Primary key exists 2. No pri...

MySQL 5.7.18 Archive compressed version installation tutorial

This article shares the specific method of instal...

Detailed basic operations on data tables in MySQL database

Table of contents 1. View the tables in the curre...

Implementation of Nginx hot deployment

Table of contents Semaphore Nginx hot deployment ...

Summary of important components of MySQL InnoDB

Innodb includes the following components 1. innod...

A simple method to implement scheduled backup of MySQL database in Linux

Here are the detailed steps: 1. Check the disk sp...