typora 标题自动加编号

网上看了挺多其他复制粘贴的方法,但是缺点都是第一级 h1 ,都算进去了

按照规范的 markdown 规范,一个 md 文件中只能出现一个 h1,就是标题

所以最大的编号应该就是 h2,所以我拿来改了一下

新建样式

Typora\themes 目录下,新建一个 base.user.css文件

导入我修改好的 css

已经集成了 标题自动编号, TOC 目录自动编号, 左侧导航栏自动编号

编号默认从 h2 开始计算

/** initialize css counter */
#write {
    counter-reset: h1
}

h1 {
    counter-reset: h2
}

h2 {
    counter-reset: h3
}

h3 {
    counter-reset: h4
}

h4 {
    counter-reset: h5
}

h5 {
    counter-reset: h6
}

/** put counter result into headings */
#write h2:before {
    counter-increment: h2;
    content: counter(h2) ". "
}

#write h3:before,
h3.md-focus.md-heading:before /** override the default style for focused headings */ {
    counter-increment: h3;
    content: counter(h2) "." counter(h3) ". "
}

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

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

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

/** override the default style for focused headings */
#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;
}

/**************************************
 * Header Counters in TOC
 **************************************/

/* No link underlines in TOC */
.md-toc-inner {
    text-decoration: none;
}

.md-toc-content {
    counter-reset: h1toc
}

.md-toc-h1 {
    margin-left: 0;
    font-size: 1.5rem;
    counter-reset: h2toc
}

.md-toc-h2 {
    font-size: 1.1rem;
    margin-left: 2rem;
    counter-reset: h3toc
}

.md-toc-h3 {
    margin-left: 3rem;
    font-size: .9rem;
    counter-reset: h4toc
}

.md-toc-h4 {
    margin-left: 4rem;
    font-size: .85rem;
    counter-reset: h5toc
}

.md-toc-h5 {
    margin-left: 5rem;
    font-size: .8rem;
    counter-reset: h6toc
}

.md-toc-h6 {
    margin-left: 6rem;
    font-size: .75rem;
}

.md-toc-h2:before {
    counter-increment: h2toc;
    content: counter(h2toc) ". "
}

.md-toc-h2 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h3:before {
    counter-increment: h3toc;
    content: counter(h2toc) ". " counter(h3toc) ". "
}

.md-toc-h3 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h4:before {
    counter-increment: h4toc;
    content: counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". "
}

.md-toc-h4 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h5:before {
    counter-increment: h5toc;
    content: counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". "
}

.md-toc-h5 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h6:before {
    counter-increment: h6toc;
    content: counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". " counter(h6toc) ". "
}

.md-toc-h6 .md-toc-inner {
    margin-left: 0;
}

/**************************************
 * Header Counters in Content
 **************************************/

/** initialize css counter */
#write {
    counter-reset: h1
}

h1 {
    counter-reset: h2
}

h2 {
    counter-reset: h3
}

h3 {
    counter-reset: h4
}

h4 {
    counter-reset: h5
}

h5 {
    counter-reset: h6
}

/** put counter result into headings */

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

#write h3:before, h3.md-focus.md-heading:before { /*override the default style for focused headings */
    counter-increment: h3;
    content: counter(h2) "." counter(h3) ". "
}

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

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

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

/** override the default style for focused headings */
#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;
}

/* Auto-Numbering Outline panel */

.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-h2>.outline-item>.outline-label:before {
    counter-increment: h2;
    content: counter(h2) ". "
}

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

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

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

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

enjoy

然后开始使用

需要注意的是,只有导出 html 的时候才能看得见这个样式,如果是直接复制是无法复制走这个序号的,如果想要复制的时候也有需要请自己写 python 脚本,或者有时间我可能会写一个

Original: https://www.cnblogs.com/BEMAKE/p/16610472.html
Author: 271374667
Title: typora 标题自动加编号

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/602797/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • IBM SPSS Statistics描述性统计分析使用教学

    本文主要将从描述性统计的定义、描述性统计的应用场景、怎么进行描述性统计三个方面来介绍描述性统计。 首先描述性统计是用来计算变量之间的差异,一般用平均值、方差、标准差这些数学公式来计…

    Python 2023年8月21日
    096
  • 78—Python 极坐标系下绘制会动的心形线

    要建立数学 _坐标系_并 _绘制_函数曲线,你可以使用 _Python_中的OpenCV库。下面是一个简单的示例代码,演示了如何 _绘制_一个函数的曲线: _python_ imp…

    Python 2023年9月3日
    090
  • 老油条表示真干不过,部门新来的00后测试员已把我卷崩溃,想离职了…

    在程序员职场上,什么样的人最让人反感呢? 是技术不好的人吗?并不是。技术不好的同事,我们可以帮他。是技术太强的人吗?也不是。技术很强的同事,可遇不可求,向他学习还来不及呢。 真正让…

    Python 2023年8月3日
    057
  • Python绘制雷达图

    Python绘制雷达图 在写论文之,可能会用到雷达图来分析实验结果,那么如何用Python来会绘制雷达图呢? 今天利用Python的matplotlib模块来绘制雷达图,一些书本上…

    Python 2023年9月4日
    045
  • 直方图均衡化

    1. 图像直方图 图像直方图,是指对整个图像在灰度范围内的像素值(0-255)统计出现频率次数,据此生成的直方图,称为图像直方图或直方图。直方图反映了图像灰度的分布情况,是图像的统…

    Python 2023年10月29日
    023
  • 简单的数据处理#学习笔记

    在数模模拟题中做过一些简单的数据处理,为了方便以后使用,做了一下记录,仅供本人学习使用 一、数据的读取 1.利用pandas读取数据 import pandas as pd f=o…

    Python 2023年8月8日
    054
  • python 字典组成的列表 pandas_Python-将嵌套字典列表转换为Pandas Dataframe

    python很多时候会从各种来源接收数据,这些数据可以采用不同的格式,例如csv,JSON等,可以转换为python列表或字典等。但是要使用诸如pandas之类的包应用计算或分析,…

    Python 2023年8月21日
    045
  • Matplotlib不显示中文解决办法

    在学习matplotlib画图过程中,难免会碰到x轴、y轴刻度、图标题、图例显示中文的情况。但是发现matplotlib默认不会显示中文,需要经过字体设置才可以。笔者在解决问题的过…

    Python 2023年8月30日
    044
  • python panda3d从入门_利用Python进行数据分析——pandas入门

    利用Python进行数据分析——pandas入门 基于NumPy建立的 from pandas importSeries,DataFrame,import pandas as pd…

    Python 2023年8月22日
    062
  • scrapy爬虫入门练习

    安装scrapy: 使用命令:pip install Scrapy 创建爬虫项目 使用命令:scrapy startproject test2 创建爬虫 使用命令:scrap ge…

    Python 2023年10月2日
    027
  • Pandas数据分析——常用操作

    引言 Pandas是一种常见且便捷的数据处理库,为便于使用和复习,个人针对一些常用操作进行了总结。 目录 引言 一、pandas是什么? 二、pandas常用操作有哪些? * 1….

    Python 2023年8月17日
    064
  • (Java)设计模式:创建型

    前言 这篇内容是从另一篇:UML建模、设计原则 中分离出来的,原本这个创建型设计模式是和其放在一起的 但是:把这篇创建型设计模式放在一起让我贼别扭,看起来贼不舒服,越看念头越不通达…

    Python 2023年10月14日
    040
  • 几个常用的Numpy函数详解

    Numpy是python中最有用的工具之一。它可以有效地处理大容量数据。使用NumPy的最大原因之一是它有很多处理数组的函数。在本文中,将介绍NumPy在数据科学中最重要和最有用的…

    Python 2023年8月28日
    077
  • scrapy 练习

    scrapy版本:初次学习是两三年之前,当时使用python2安装scrapy。scrapy版本1.7.3。现在看安装指南已经要求python 3.6+。scrapy版本已经是2….

    Python 2023年10月2日
    050
  • 怎样编写正确、高效的 Dockerfile

    基础镜像 FROM 基础镜像基础镜像的选择非常关键: 如果关注的是镜像的安全和大小,那么一般会选择 Alpine; 如果关注的是应用的运行稳定性,那么可能会选择 Ubuntu、De…

    Python 2023年10月21日
    032
  • Python库之numpy之数组切片

    众所周知,python中有很多的库,numpy就是其中的一个库,做数据分析必备的库之一,今天就让我们来学一下,numpy的切片 今天上课学这个切片切的我快自卑了,为啥为啥,脑子里全…

    Python 2023年8月29日
    050
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球