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/685065/

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

(0)

大家都在看

  • 内存泄漏定位工具之 valgrind 使用

    前面介绍了 GCC 自带的 mtrace 内存泄漏检查工具,该篇主要介绍开源的内存泄漏工具 valgrind,valgrind 是一套 Linux 下,开放源代码的动态调试工具集合…

    技术杂谈 2023年7月25日
    087
  • c#常用快捷键

    相信.Net开发人员都想能够熟记各种VS快捷键以提高平时开发的效率,但苦于记忆能力太差而快捷键又特别多,特别烦,所以作罢! 下面我将简单介绍一下我记忆VS快捷键的一些方法,希望对大…

    技术杂谈 2023年7月24日
    080
  • 汇编语言

    汇编语言一发入魂 – 杨河老李 (kviccn.github.io) posted @2022-05-10 21:14 Bigben 阅读(41 ) 评论() 编辑 Origina…

    技术杂谈 2023年5月31日
    090
  • Reactor模型

    要无障碍阅读本文,需要对NIO有一个大概的了解,起码要可以写一个NIO的Hello World。 说到NIO、Netty,Reactor模型一定是绕不开的,因为这种模式架构太经典了…

    技术杂谈 2023年7月25日
    057
  • kettle中变量的设置和使用介绍

    有没有能统一管理一个参数,然后让所有的transformation和job都可以读到呢? 答案是有 1.首先,打开.kettlekettle.properties(个人主机是:C:…

    技术杂谈 2023年5月31日
    096
  • jenkin部署(docker+gitlab)

    第一部分 安装部署 1.1 gitlab安装部署 最小配置 内存至少4g,系统内核至少在3.10以上 uname -r 可查看系统内核版本 默认docker已经安装 1、安装git…

    技术杂谈 2023年7月24日
    082
  • ElasticSearch-全文检索(一)

    ElasticSearch–全文检索(一) 为什么要用ElasticSearch?它可以解决什么问题? 中文文档:使用聚合分析结果 (bookhub.zone) htt…

    技术杂谈 2023年7月10日
    088
  • EMAS Serverless系列~4步教你快速搭建小程序

    体验简介 本实验基于 EMAS Serverless 的云函数、云数据库、云存储等云服务能力一站式快速开发小程序《私人云相册》。Demo 主要包括如下功能:1 相册管理2 上传相片…

    技术杂谈 2023年7月10日
    088
  • Linux中的grep,sed,find的使用方法

    提取指定文件到指定目录/文件 语法:tar xvf test.tar test1(只提取test.tar 包中的test1文件到当前路径) 语法:tar xvf test.tar …

    技术杂谈 2023年7月24日
    065
  • Clickhouse的MergeTree表引擎存储结构

    MergeTree存储的文件结构 一张数据表被分成几个data part,每个data part对应文件系统中的一个目录。通过以下SQL可以查询data parts的信息。 sel…

    技术杂谈 2023年7月24日
    082
  • Linux的目录结构

    Linux 的文件系统是采用级层式的树状目录结构,在此结构中的最上层是根目录”/”,然后在此目录下再创建其他的目录,在Java 中是一切皆对象,在linux…

    技术杂谈 2023年7月24日
    0103
  • Prometheus监控oracle的配置

    告警https://sysdig.com/blog/monitor-oracle-database-prometheus/ Prometheus监控oracle的配置1、下载ora…

    技术杂谈 2023年5月31日
    062
  • M1 MAC 装ubuntu更换镜像源

    记录一下今天突发奇想装个ubuntu遇到问题 w镜像源:更换镜像源网上教程基本对的,但要注意机型(ps:m1 mac) 补:很多时候是对问题理解不到位,比如我直接搜索arm ubu…

    技术杂谈 2023年7月11日
    084
  • InnoDB中不同SQL语句设置的锁

    锁定读、UPDATE 或 DELETE 通常会给在SQL语句处理过程扫描到的每个索引记录上设置记录锁。语句中是否存在排除该行的WHERE条件并不重要。InnoDB不记得确切的WHE…

    技术杂谈 2023年7月24日
    062
  • 【赵渝强老师】使用Oracle的跟踪文件

    一、什么是跟踪文件? 跟踪文件中包含了大量而详细的诊断和调试信息。通过对跟踪文件的解读和分析,我们可以定位问题、分析问题和解决问题。从跟踪文件的产生的来源来看,跟踪文件又可以分为两…

    技术杂谈 2023年7月24日
    073
  • 4个步骤,查询硬盘序列号

    摘自:https://m.hqew.com/tech/news_2064115 diskpart list disk select disk 0 detail disk Origi…

    技术杂谈 2023年5月31日
    091
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球