Typora代码块配色和标题自带序号的实现代码

  发布时间:2020-11-20 14:56:55   作者:月 夕   我要评论
这篇文章主要介绍了Typora代码块配色和标题自带序号的实现代码,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

效果:标题自带序号,代码块配色,代码块左上角仿mac图标

在这里插入图片描述

先打开主题文件夹

文件>偏好设置>外观>打开主题文件夹

然后编辑base.user.css(如果没有就新建一个)文件

将以下代码加入即可

/*标题自动添加序号*/
.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;
}
/*因为不同主题的代码块部分不一样,code部分统一*/
.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;
}



/*深色背景*/

#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;
}


/*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;
}

/*配色*/
.CodeMirror-line .cm-number,/*数字*/
.CodeMirror-line .cm-property {/*被调用的方法*/
    color: #f08d49;
}
.CodeMirror-line .cm-variable-3,/*形参,类型*/
.CodeMirror-line .cm-qualifier,/*css class*/
.CodeMirror-line .cm-variable-2 {/*被使用的形参*/
    color: #FFCB6B;
}
.CodeMirror-line .cm-meta,/*省略号,注解等*/
.CodeMirror-line .cm-atom,/*css属性值,布尔值等等*/
.CodeMirror-line .cm-keyword{/*关键字*/
    color: #cc99cd;
}
.CodeMirror-line .cm-def,/*变量名*/
.CodeMirror-line .cm-variable {/*被使用的变量名*/
    color: #FFCB6B;
}
.CodeMirror-line .cm-builtin {/*被调用的属性*/
    color: #82AAFF;
}
.CodeMirror-line .cm-comment {/*注释*/
    color: #888;
}
.CodeMirror-line .cm-string,/*字符串*/
.CodeMirror-line .cm-string-2 {/*正则表达式*/
    color: #7ec699
}
.CodeMirror-line .cm-operator {/*运算符*/
    color: #67cdcc
}
.CodeMirror div.CodeMirror-cursor {/*光标*/
    border-left: 1px solid #fff;
    z-index: 3;
}
.CodeMirror-selected,/*选中的背景*/
.CodeMirror-selectedtext {
    background: #666 !important;
}

/*html*/
.CodeMirror-line .cm-tag{/*标签名字*/
    color: #F07178;
}
.CodeMirror-line .cm-bracket{/*标签尖括号*/
    color: #FFF;
}
.CodeMirror-line .cm-attribute{/*属性*/
    color: #FFCB6B;
}

到此这篇关于Typora代码块配色和标题自带序号的实现代码的文章就介绍到这了,更多相关Typora代码块内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

相关文章

  • 使用CSS+HTML实现简单的魔幻霓虹灯文字特效

    这篇文章主要介绍了使用CSS+HTML实现简单的魔幻霓虹灯文字特效,CSS 能够对网页中元素位置的排版进行像素级精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样
    2023-05-08
  • css实现电梯导航的项目实践

    CSS梯形导航图是一种使用 CSS 布局实现的导航设计,可以根据需要灵活调整导航菜单的上下位置和大小,本文主要介绍了css实现电梯导航,具有一定的参考价值,感兴趣的可以了解
    2023-05-06
  • CSS中calc(100%-100px)不加空格不生效

    本文主要介绍了CSS中calc(100%-100px)不加空格不生效,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学
    2023-05-05
  • css弧边选项卡的项目实践

    本文主要介绍了css弧边选项卡的项目实践,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-05-05
  • CSS实现鼠标悬浮动画特效

    Css(层叠样式表)是种格式化网页的标准方式,用于控制设置网页的样式,并且允许CSS样式信息与网页内容(由HTML语言定义)分离的一种技术,使用css可以制作各种好看的动画特效,
    2023-05-04
  • CSS link与@import的区别和用法解析

    CSS的link和@import都是用于引入外部CSS文件的方法,但它们有一些区别和不同的用法,本文通过一个简单的代码演示,展示了link和@import的用法,感兴趣的朋友跟随小编一起看
    2023-05-04
  • 使用CSS实现百叶窗效果示例代码

    这篇文章主要介绍了使用CSS实现百叶窗效果示例代码,技术上只使用了css+html,还是非常容易学习的,做出来的百叶窗效果也是很丝滑,文中提供了详细的代码,需要的朋友可以参考
    2023-04-28
  • 使用CSS实现按钮边缘跑马灯动画

    这篇文章主要介绍了使用CSS实现按钮边缘跑马灯动画,技术上只使用了css+html,还是非常容易学习的,文中提供了详细的代码,需要的朋友可以参考下
    2023-04-28
  • css旋转导航的示例代码

    本文主要介绍了css旋转导航的示例代码,文中通过示例代码介绍的非常详细,该导航可用在一些网站首页导航栏中,需要的朋友们下面随着小编来一起学习学习吧
    2023-04-27
  • css实现交融文字效果的项目实践

    这篇文章将介绍如何使用CSS实现交融文字效果,这是一种独特的标题设计,可以增加页面的视觉吸引力和用户体验。通过使用CSS的letter-spacing属性,我们可以创建出字母之间交
    2023-04-27

最新评论