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

  1. 先打开主题文件夹
  2. 文件>偏好设置>外观>打开主题文件夹
  3. 然后编辑base.user.css(如果没有就新建一个)文件
/*标题自动添加序号*/
.sidebar-content {
``counter-reset``: h``1
}
.outline-h``1` `{
``counter-reset``: h``2
}
.outline-h``2` `{
``counter-reset``: h``3
}
.outline-h``3` `{
``counter-reset``: h``4
}
.outline-h``4` `{
``counter-reset``: h``5
}
.outline-h``5` `{
``counter-reset``: h``6
}
.outline-h``1``>.outline-item>.outline-label:before {
``counter-increment``: h``1``;
``content``: ``counter``(h``1``) ``" "
}
.outline-h``2``>.outline-item>.outline-label:before {
``counter-increment``: h``2``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``" "
}
.outline-h``3``>.outline-item>.outline-label:before {
``counter-increment``: h``3``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``" "
}
.outline-h``4``>.outline-item>.outline-label:before {
``counter-increment``: h``4``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``"."``counter``(h``4``) ``" "
}
.outline-h``5``>.outline-item>.outline-label:before {
``counter-increment``: h``5``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``"."``counter``(h``4``) ``"."``counter``(h``5``) ``" "
}
.outline-h``6``>.outline-item>.outline-label:before {
``counter-increment``: h``6``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``"."``counter``(h``4``) ``"."``counter``(h``5``) ``"."``counter``(h``6``) ``" "
}
#write {
``counter-reset``: h``1
}
h``1` `{
``counter-reset``: h``2
}
h``2` `{
``counter-reset``: h``3
}
h``3` `{
``counter-reset``: h``4
}
h``4` `{
``counter-reset``: h``5
}
h``5` `{
``counter-reset``: h``6
}
#write h``1:``before {
``counter-increment``: h``1``;
``content``: ``counter``(h``1``) ``" "
}
#write h``2:``before {
``counter-increment``: h``2``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``" "
}
#write h``3:``before,
h``3``.md-focus.md-heading:before
  ``{
``counter-increment``: h``3``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``" "
}
#write h``4:``before,
h``4``.md-focus.md-heading:before {
``counter-increment``: h``4``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``"."``counter``(h``4``) ``" "
}
#write h``5:``before,
h``5``.md-focus.md-heading:before {
``counter-increment``: h``5``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``"."``counter``(h``4``) ``"."``counter``(h``5``) ``" "
}
#write h``6:``before,
h``6``.md-focus.md-heading:before {
``counter-increment``: h``6``;
``content``: ``counter``(h``1``) ``"."``counter``(h``2``) ``"."``counter``(h``3``) ``"."``counter``(h``4``) ``"."``counter``(h``5``) ``"."``counter``(h``6``) ``" "
}
#write>h``3``.md-focus:before,
#write>h``4``.md-focus:before,
#write>h``5``.md-focus:before,
#write>h``6``.md-focus:before,
h``3``.md-focus:before,
h``4``.md-focus:before,
h``5``.md-focus:before,
h``6``.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``: ``1``rem;
``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``: .``375``rem;
}
/*深色背景*/
#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``;
}

参考:https://www.jb51.net/css/753133.html

Typora代码块配色和标题自带序号的实现代码的更多相关文章

  1. 构造代码块、this关键字、静态变量、静态代码块、主函数

    一.构造代码块: 作用:给对象进行初始化. 特点:对象一经运行就执行(与变量声明时赋初值同级别,此处注意 非法前向引用) 优先于构造函数的执行. 与构造函数的区别: 构造代码块是给所有对象统一初始化. ...

  2. 子类A继承父类B, A a = new A(); 则父类B构造函数、父类B静态代码块、父类B非静态代码块、子类A构造函数、子类A静态代码块、子类A非静态代码块 执行的先后顺序是

    按照先后顺序: 1,静态先于非静态代码库执行(静态代码块随着类的加载而加载,初始化只执行一次) 2,父类先于子类 3,非静态代码块优于构造函数执行 所以执行顺序如下: 父类B静态代码块->子类A ...

  3. Confluence代码块(Code Block)宏

    有时候现在wiki上插入代码,如何让代码高亮,变的有颜色,下面这篇文章可能会帮助你,先看下django代码高亮效果图 代码块(Code Block)宏允许你在 Confluence 页面中显示代码,并 ...

  4. (转)java中静态代码块的用法 static用法详解

    一)java 静态代码块 静态方法区别一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的;需要在项目启动的时候就初始化,在不创建对象的情况下,其他程序来 ...

  5. [Java基础]代码块及java反编译

    块的作用域:   块(即复合语句)是指一对花括号括起来的若干条简单的java语句.块确定了变量的作用域.一个块可以嵌套在另一个块中.但是,在嵌套的两个块中声明同名的变量时应注意,块中变量申明在块外变量 ...

  6. 从C#到Objective-C,循序渐进学习苹果开发(4)--代码块(block)和错误异常处理的理解

    本随笔系列主要介绍从一个Windows平台从事C#开发到Mac平台苹果开发的一系列感想和体验历程,本系列文章是在起步阶段逐步积累的,希望带给大家更好,更真实的转换历程体验.本文继续上一篇随笔<从 ...

  7. iOS端项目注释规范附统一代码块

    代码的注释经常被人忽略,以至于在后期维护的时候较为困难.我们准备在XX项目开始之前制定一套规范的注释体系,致力于达到就算维护人员改变也能快速上手的效果. 1.属性注释 属性注释 使用 /** 注释*/ ...

  8. java基础--java静态代码块和静态方法的区别、static用法

    转载自: http://blog.sina.com.cn/s/blog_afddb8ff0101aqs9.html 静态代码块:有些代码必须在项目启动的时候就执行,这种代码是主动执行的(当类被载入时, ...

  9. java中静态代码块的用法 static用法详解(转)

    (一)java 静态代码块 静态方法区别一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的;需要在项目启动的时候就初始化,在不创建对象的情况下,其他程序 ...

随机推荐

  1. vue 使用 lang="scss" 报错

    npm install sass-loader@7.3.1 --save-dev npm install node-sass --save npm install style-loader --sav ...

  2. 论文笔记:(CVPR2019)Relation-Shape Convolutional Neural Network for Point Cloud Analysis

    目录 摘要 一.引言 二.相关工作 基于视图和体素的方法 点云上的深度学习 相关性学习 三.形状意识表示学习 3.1关系-形状卷积 建模 经典CNN的局限性 变换:从关系中学习 通道提升映射 3.2性 ...

  3. netty系列之:netty架构概述

    目录 简介 netty架构图 丰富的Buffer数据机构 零拷贝 统一的API 事件驱动 其他优秀的特性 总结 简介 Netty为什么这么优秀,它在JDK本身的NIO基础上又做了什么改进呢?它的架构和 ...

  4. Yara规则学习

    01 定义 官网: YARA is a tool aimed at (but not limited to) helping malware researchers to identify and c ...

  5. Android菜鸟进字节跳动,居然是看了这个......

    谈谈我的真实感受吧- 程序员真的是需要将终生学习贯彻到底的职业,一旦停止学习,离被淘汰,也就不远了. 金三银四.金九银十跳槽季,这是一个千年不变的话题,每到这个时候,很多人都会临阵磨枪,相信不快也光. ...

  6. Android面试中多说这么一句话,薪水直接涨5k

    小鱼同学最近很难受,明明获得了人人羡慕的大厂Offer,走在路上都能被熟人祝贺,学弟学妹争着抢着求他进行经验分享. 但有件事一直让他很介意.其实这件事起因很简单,是关于这份Offer的薪资问题,面试的 ...

  7. Android源码解析——Handler、Looper与MessageQueue

    本文的目的是来分析下 Android 系统中以 Handler.Looper.MessageQueue 组成的异步消息处理机制,通过源码来了解整个消息处理流程的走向以及相关三者之间的关系 需要先了解以 ...

  8. Blazor 模板化组件开发指南

    翻译自 Waqas Anwar 2021年4月15日的文章 <A Developer's Guide To Blazor Templated Components> [1] 在我之前的一篇 ...

  9. Flink EOS如何防止外部系统乱入--两阶段提交源码

    一.前言 根据维基百科的定义,两阶段提交(Two-phase Commit,简称2PC)是巨人们用来解决分布式系统架构下的所有节点在进行事务提交时保持一致性问题而设计的一种算法,也可称之为协议. 在F ...

  10. Linux从头学07:中断那么重要,它的本质到底是什么?

    作 者:道哥,10+年的嵌入式开发老兵. 公众号:[IOT物联网小镇],专注于:C/C++.Linux操作系统.应用程序设计.物联网.单片机和嵌入式开发等领域. 公众号回复[书籍],获取 Linux. ...