From 6864160c51f4da22747b12634241b32c2edb1bb6 Mon Sep 17 00:00:00 2001 From: Linho Date: Tue, 17 Dec 2024 17:10:39 +0800 Subject: [PATCH 1/6] feat: Modify and footnote superscript styles to match LaTeX theme Remove footnote superscript background and padding; adjust brackets and spacing of footnote labels --- src/scss/footnote.scss | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index db41b6b..ba2f617 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -4,6 +4,7 @@ $theme: "" !default; /* 参考文献(脚注)块 */ .footnotes { font-size: 0.95em; + opacity: 1; } .footnotes-area { .footnote-line { @@ -16,3 +17,35 @@ $theme: "" !default; color: #00000000; } } +.md-def-footnote { + .md-def-name { + padding: 0; + margin: 0.2em 0; + + &:before { + content: "["; + position: static; + color: inherit; + } + &:after { + content: "]"; + position: static; + color: inherit; + } + } + .md-reverse-footnote-area { + display: none; + } + &:hover .md-reverse-footnote-area { + display: inline; + } +} + +/* 参考文献(脚注)上标 */ +sup.md-footnote { + display: inline; + padding: 0; + margin: 0; + background: transparent; + color: inherit; +} \ No newline at end of file From 864d0d99b4b39740a625abd7ec2817b854147d61 Mon Sep 17 00:00:00 2001 From: Keldos Date: Thu, 19 Dec 2024 00:44:21 +0800 Subject: [PATCH 2/6] feat: Superscript footnotes in the text with "[ ]" --- src/scss/footnote.scss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index ba2f617..e8f745f 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -48,4 +48,15 @@ sup.md-footnote { margin: 0; background: transparent; color: inherit; + + // 显示 markdown 预览,而没有点击展开显示尾注内容时 + &:not(.md-expand) { + margin-inline: -0.44em; + &:before { + content: "["; + } + &:after { + content: "]"; + } + } } \ No newline at end of file From 3d05119dca61a973d201a7bea4c08897bb3d8651 Mon Sep 17 00:00:00 2001 From: Keldos Date: Thu, 19 Dec 2024 14:22:56 +0800 Subject: [PATCH 3/6] feat: adjust spacing between consecutive footnotes --- src/scss/footnote.scss | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index e8f745f..a55b0f7 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -5,7 +5,16 @@ $theme: "" !default; .footnotes { font-size: 0.95em; opacity: 1; + margin: 0; + &:not(:first-child), + & + *:not(.footnotes) { + margin-top: 1em; + } + & + .footnotes { + margin-top: 0.5em; + } } + .footnotes-area { .footnote-line { color: var(--text-color); @@ -19,8 +28,8 @@ $theme: "" !default; } .md-def-footnote { .md-def-name { + font-weight: inherit; padding: 0; - margin: 0.2em 0; &:before { content: "["; @@ -38,6 +47,7 @@ $theme: "" !default; } &:hover .md-reverse-footnote-area { display: inline; + font-size: 0.85em; } } From e887117abe94aced7fdd0139e11dec3c16642122 Mon Sep 17 00:00:00 2001 From: Keldos Date: Thu, 19 Dec 2024 16:15:57 +0800 Subject: [PATCH 4/6] feat: align footnote numbers and the indented annotation text --- src/scss/footnote.scss | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index a55b0f7..863742d 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -3,6 +3,8 @@ $theme: "" !default; /* 参考文献(脚注)块 */ .footnotes { + display: flex; + position: relative; font-size: 0.95em; opacity: 1; margin: 0; @@ -30,6 +32,10 @@ $theme: "" !default; .md-def-name { font-weight: inherit; padding: 0; + margin-inline-end:-1ch; + flex-shrink: 0; + width: 3em; + text-align: right; &:before { content: "["; @@ -46,8 +52,10 @@ $theme: "" !default; display: none; } &:hover .md-reverse-footnote-area { + position: absolute; + right: -6px; display: inline; - font-size: 0.85em; + // font-size: 0.85em; } } From 348d93541d9e6147eb0b941efbf5852cbf8d44d9 Mon Sep 17 00:00:00 2001 From: Keldos Date: Fri, 27 Dec 2024 20:42:40 +0800 Subject: [PATCH 5/6] feat: apply style to exported pdf --- src/scss/footnote.scss | 68 +++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index 863742d..4816cd4 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -2,40 +2,28 @@ $os: "" !default; $theme: "" !default; /* 参考文献(脚注)块 */ -.footnotes { +.md-def-footnote { display: flex; position: relative; font-size: 0.95em; opacity: 1; margin: 0; &:not(:first-child), - & + *:not(.footnotes) { + & + *:not(.md-def-footnote) { margin-top: 1em; } - & + .footnotes { + & + .md-def-footnote { margin-top: 0.5em; } -} -.footnotes-area { - .footnote-line { - color: var(--text-color); - } - - // 默认情况下,Typora 会给参考文献块顶部加一条横线,这里把它隐藏掉 - hr { - border: 0; - color: #00000000; - } -} -.md-def-footnote { .md-def-name { font-weight: inherit; padding: 0; - margin-inline-end:-1ch; flex-shrink: 0; width: 3em; - text-align: right; + margin-inline-start: -1ch; + white-space: nowrap; + text-align: left; &:before { content: "["; @@ -59,6 +47,47 @@ $theme: "" !default; } } +/* + * 导出时 HTML 和 PDF 的配置需要单独写一遍。但是由于 HTML 结构的不同,使用的方法并不一样。 + */ +.footnotes-area { + padding-inline-start: 2.5em; + // 默认情况下,Typora 会给参考文献块顶部加一条横线,这里把它隐藏掉 + hr { + display: none; + } + .footnote-line { + color: var(--text-color); + font-size: 0.95em; + margin-top: 0.5em; + + *:not(.md-fn-count) { + display: inline-block; + vertical-align: top; + } + span.md-fn-count { + font-weight: inherit; + padding: 0; + margin-inline-start: -3em; + white-space: nowrap; + display: inline-block; + width: 2.5em; + &:before { + content: "["; + position: static; + color: inherit; + } + &:after { + content: "]"; + position: static; + color: inherit; + } + } + a.reversefootnote { + display: none; + } + } +} /* 参考文献(脚注)上标 */ sup.md-footnote { display: inline; @@ -66,6 +95,9 @@ sup.md-footnote { margin: 0; background: transparent; color: inherit; + a { + color: inherit !important; // 导出时的a是单独的必须再次设置 + } // 显示 markdown 预览,而没有点击展开显示尾注内容时 &:not(.md-expand) { From 20aaa92b64b79d41a0141733d0adcf653e6a7d1c Mon Sep 17 00:00:00 2001 From: RalXYZ Date: Sun, 5 Jan 2025 15:19:53 +0800 Subject: [PATCH 6/6] chore: add comments --- src/scss/footnote.scss | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index 4816cd4..1bf4b8c 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -1,13 +1,14 @@ $os: "" !default; $theme: "" !default; -/* 参考文献(脚注)块 */ +/* 参考文献(脚注)块,在 Typora 中的样式 */ .md-def-footnote { display: flex; position: relative; font-size: 0.95em; opacity: 1; margin: 0; + &:not(:first-child), & + *:not(.md-def-footnote) { margin-top: 1em; @@ -36,6 +37,8 @@ $theme: "" !default; color: inherit; } } + + // 默认隐藏行尾的 ↩️,仅在鼠标悬停时显示 .md-reverse-footnote-area { display: none; } @@ -43,19 +46,18 @@ $theme: "" !default; position: absolute; right: -6px; display: inline; - // font-size: 0.85em; } } -/* - * 导出时 HTML 和 PDF 的配置需要单独写一遍。但是由于 HTML 结构的不同,使用的方法并不一样。 - */ +/* 参考文献(脚注)块,在导出 HTML 或 PDF 时的样式(导出后的 HTML tag 和 Typora 中的 HTML tag 不一致) */ .footnotes-area { padding-inline-start: 2.5em; + // 默认情况下,Typora 会给参考文献块顶部加一条横线,这里把它隐藏掉 hr { display: none; } + .footnote-line { color: var(--text-color); font-size: 0.95em; @@ -65,6 +67,7 @@ $theme: "" !default; display: inline-block; vertical-align: top; } + span.md-fn-count { font-weight: inherit; padding: 0; @@ -83,11 +86,13 @@ $theme: "" !default; color: inherit; } } + a.reversefootnote { display: none; } } } + /* 参考文献(脚注)上标 */ sup.md-footnote { display: inline; @@ -109,4 +114,4 @@ sup.md-footnote { content: "]"; } } -} \ No newline at end of file +}