From a3b4a5343cce149e8e12b264e73ceefa9ee77e23 Mon Sep 17 00:00:00 2001 From: RalXYZ Date: Fri, 22 Nov 2024 23:24:24 +0800 Subject: [PATCH 1/4] fix: update dart-sass to 1.81.0, enhance makefile performance use @use instead of @import update dart-sass to 1.81.0 modify the makefile to enable more efficient concurrent builds --- .github/workflows/dev-build.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- src/Makefile | 15 ++++----------- src/headers/linux/dark.scss | 4 ---- src/headers/linux/light.scss | 4 ---- src/headers/macos/dark.scss | 4 ---- src/headers/macos/light.scss | 4 ---- src/headers/windows/dark.scss | 4 ---- src/headers/windows/light.scss | 4 ---- src/scss/code.scss | 6 ++++-- src/scss/dark.scss | 4 +++- src/scss/env.scss | 2 ++ src/scss/heading.scss | 8 +++++--- src/scss/include.scss | 22 +++++++++++----------- src/scss/settings.scss | 16 +++++++++------- src/scss/text.scss | 16 +++++++++------- src/scss/toc.scss | 10 ++++++---- src/scss/typora.scss | 14 ++++++++------ 18 files changed, 65 insertions(+), 80 deletions(-) delete mode 100644 src/headers/linux/dark.scss delete mode 100644 src/headers/linux/light.scss delete mode 100644 src/headers/macos/dark.scss delete mode 100644 src/headers/macos/light.scss delete mode 100644 src/headers/windows/dark.scss delete mode 100644 src/headers/windows/light.scss create mode 100644 src/scss/env.scss diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 3611445..cb4bf08 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -8,7 +8,7 @@ on: types: [opened, synchronize, reopened] env: - DART_SASS_VERSION: 1.79.6 + DART_SASS_VERSION: 1.81.0 jobs: compile: @@ -28,7 +28,7 @@ jobs: echo "$GITHUB_WORKSPACE/dart-sass" >> "$GITHUB_PATH" - name: Compile run: | - cd ./src; make + cd ./src; make -j3 - name: Upload Artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index feae70e..ff475c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - v* env: - DART_SASS_VERSION: 1.79.6 + DART_SASS_VERSION: 1.81.0 jobs: release: @@ -26,7 +26,7 @@ jobs: echo "$GITHUB_WORKSPACE/dart-sass" >> "$GITHUB_PATH" - name: Compile run: | - cd ./src; make all-and-compress + cd ./src; make all-and-compress -j3 - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') diff --git a/src/Makefile b/src/Makefile index ad25461..68fd4fb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,16 +12,15 @@ $(shell mkdir -p $(working_dir)) $(shell mkdir -p $(target_dir)) $(shell cp -r $(base_dir)/scss $(working_dir)/scss) -$(shell cp -r $(base_dir)/headers $(working_dir)/headers) # $(1) is the name of operating system, $(2) is typora or pandoc, $(3) is light or dark theme define build mkdir -p $(target_dir)/$(1)-$(2) mkdir -p $(target_dir)/$(1)-$(2)/target if [ "$(3)" = "light" ]; then \ - sass --no-source-map --style expanded $(working_dir)/headers/$(1)/$(3).scss $(target_dir)/$(1)-$(2)/target/latex.css; \ + TYPORA_LATEX_THEME_BUILD_OS=$(1) TYPORA_LATEX_THEME_BUILD_THEME=$(3) dart-sass --no-source-map --style expanded $(working_dir)/scss/include.scss $(target_dir)/$(1)-$(2)/target/latex.css; \ else \ - sass --no-source-map --style expanded $(working_dir)/headers/$(1)/$(3).scss $(target_dir)/$(1)-$(2)/target/latex-$(3).css; \ + TYPORA_LATEX_THEME_BUILD_OS=$(1) TYPORA_LATEX_THEME_BUILD_THEME=$(3) dart-sass --no-source-map --style expanded $(working_dir)/scss/include.scss $(target_dir)/$(1)-$(2)/target/latex-$(3).css; \ fi endef @@ -46,19 +45,13 @@ define build-pandoc endef .PHONY: all -all: - make windows - make macos - make linux - make pandoc +all: windows macos linux .PHONY: all-and-compress -all-and-compress: - make all +all-and-compress: all cd $(target_dir)/$(windows)-$(typora); zip -r $(target_dir)/latex-theme-$(windows).zip ./* cd $(target_dir)/$(macos)-$(typora); zip -r $(target_dir)/latex-theme-$(macos).zip ./* cd $(target_dir)/$(linux)-$(typora); zip -r $(target_dir)/latex-theme-$(linux).zip ./* -# cd $(target_dir)/$(pandoc)-$(typora); zip -r $(target_dir)/latex-theme-$(pandoc).zip ./* .PHONY: windows windows: diff --git a/src/headers/linux/dark.scss b/src/headers/linux/dark.scss deleted file mode 100644 index edea439..0000000 --- a/src/headers/linux/dark.scss +++ /dev/null @@ -1,4 +0,0 @@ -$os: "linux"; -$theme: "dark"; - -@import "../../scss/include.scss"; diff --git a/src/headers/linux/light.scss b/src/headers/linux/light.scss deleted file mode 100644 index 22faec3..0000000 --- a/src/headers/linux/light.scss +++ /dev/null @@ -1,4 +0,0 @@ -$os: "linux"; -$theme: "light"; - -@import "../../scss/include.scss"; diff --git a/src/headers/macos/dark.scss b/src/headers/macos/dark.scss deleted file mode 100644 index 2c103c4..0000000 --- a/src/headers/macos/dark.scss +++ /dev/null @@ -1,4 +0,0 @@ -$os: "macos"; -$theme: "dark"; - -@import "../../scss/include.scss"; diff --git a/src/headers/macos/light.scss b/src/headers/macos/light.scss deleted file mode 100644 index b2613eb..0000000 --- a/src/headers/macos/light.scss +++ /dev/null @@ -1,4 +0,0 @@ -$os: "macos"; -$theme: "light"; - -@import "../../scss/include.scss"; diff --git a/src/headers/windows/dark.scss b/src/headers/windows/dark.scss deleted file mode 100644 index cbb98c7..0000000 --- a/src/headers/windows/dark.scss +++ /dev/null @@ -1,4 +0,0 @@ -$os: "windows"; -$theme: "dark"; - -@import "../../scss/include.scss"; diff --git a/src/headers/windows/light.scss b/src/headers/windows/light.scss deleted file mode 100644 index 1d474b6..0000000 --- a/src/headers/windows/light.scss +++ /dev/null @@ -1,4 +0,0 @@ -$os: "windows"; -$theme: "light"; - -@import "../../scss/include.scss"; diff --git a/src/scss/code.scss b/src/scss/code.scss index 558c903..0193576 100644 --- a/src/scss/code.scss +++ b/src/scss/code.scss @@ -1,3 +1,5 @@ +@use "env"; + /* 行内代码 */ code { font-family: var(--code-font), var(--ui-font), monospace; @@ -5,12 +7,12 @@ code { h1 code, h2 code, h3 code, h4 code, h5 code, h6 code, p code, li code { - @if $theme == "light" { + @if env.$theme == "light" { color: rgb(60, 112, 198); background-color: #fefefe; /* 阴影 */ box-shadow: 0 0 1px 1px #c8d3df; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { /* 黑色模式修改 */ color: #8bb1f9; /* 黑色模式修改 */ diff --git a/src/scss/dark.scss b/src/scss/dark.scss index 38a00ba..0df6005 100644 --- a/src/scss/dark.scss +++ b/src/scss/dark.scss @@ -1,4 +1,6 @@ -@if $theme == "dark" { +@use "env"; + +@if env.$theme == "dark" { /* 可能的代码高亮样式 .cm-s-inner { background-color: #263238; diff --git a/src/scss/env.scss b/src/scss/env.scss new file mode 100644 index 0000000..1be5fd5 --- /dev/null +++ b/src/scss/env.scss @@ -0,0 +1,2 @@ +$os: env(TYPORA_LATEX_THEME_BUILD_OS); +$theme: env(TYPORA_LATEX_THEME_BUILD_THEME); diff --git a/src/scss/heading.scss b/src/scss/heading.scss index 050966d..0455bce 100644 --- a/src/scss/heading.scss +++ b/src/scss/heading.scss @@ -1,3 +1,5 @@ +@use "env"; + #write { // 标题属性 h1, @@ -6,9 +8,9 @@ h4, h5, h6 { - @if $os == "windows" { + @if env.$os == "windows" { font-weight: bold; - } @else if $os == "macos" { + } @else if env.$os == "macos" { font-weight: normal; } break-after: avoid-page !important; @@ -16,7 +18,7 @@ h1 { font-family: var(--heading-Latin-font), var(--title-Chinese-font), serif; - @if $os == "macos" { + @if env.$os == "macos" { font-weight: normal; } text-align: center; diff --git a/src/scss/include.scss b/src/scss/include.scss index 897984b..dc81a10 100644 --- a/src/scss/include.scss +++ b/src/scss/include.scss @@ -1,14 +1,14 @@ -@import "./settings.scss"; +@use "./settings.scss"; -@import "./text.scss"; -@import "./typora.scss"; +@use "./text.scss"; +@use "./typora.scss"; -@import "./heading.scss"; -@import "./footnote.scss"; -@import "./list.scss"; -@import "./table.scss"; -@import "./blockquote.scss"; -@import "./code.scss"; -@import "./toc.scss"; +@use "./heading.scss"; +@use "./footnote.scss"; +@use "./list.scss"; +@use "./table.scss"; +@use "./blockquote.scss"; +@use "./code.scss"; +@use "./toc.scss"; -@import "./dark.scss"; +@use "./dark.scss"; diff --git a/src/scss/settings.scss b/src/scss/settings.scss index 42485e7..2735333 100644 --- a/src/scss/settings.scss +++ b/src/scss/settings.scss @@ -1,22 +1,24 @@ +@use "env"; + :root { $ui-font: null; $heading-Chinese-font: null; $chapter-Chinese-font: null; $sub-chapter-Chinese-font: null; $sub-sub-chapter-Chinese-font: null; - @if $os == "windows" { + @if env.$os == "windows" { $ui-font: "\"阿里巴巴普惠体 2.0\"", "\"微软雅黑\""; $heading-Chinese-font: "华文黑体"; $chapter-Chinese-font: "华文黑体"; $sub-chapter-Chinese-font: "华文楷体"; $sub-sub-chapter-Chinese-font: "华文仿宋"; - } @else if $os == "macos" { + } @else if env.$os == "macos" { $ui-font: "\"苹方-简\""; $heading-Chinese-font: "华文黑体Bold"; $chapter-Chinese-font: "方正公文黑体"; $sub-chapter-Chinese-font: "方正公文楷体"; $sub-sub-chapter-Chinese-font: "方正公文仿宋"; - } @else if $os == "linux" { + } @else if env.$os == "linux" { $ui-font: "\"Noto Sans CJK SC\""; $heading-Chinese-font: "Noto Sans CJK SC"; $chapter-Chinese-font: "Noto Sans CJK SC"; @@ -69,14 +71,14 @@ --table-font: ""; /* 标题字体(总设置) */ - @if $os == "macos" { + @if env.$os == "macos" { /* 注意,如果您使用macOS系统并更改了英文字体,请在此处更换标题英文字体粗体字重的postscript值 */ --heading-Latin-font: "LMRoman10-Bold"; --heading-Chinese-font: "#{$heading-Chinese-font}"; - } @else if $os == "windows" { + } @else if env.$os == "windows" { --heading-Latin-font: var(--base-Latin-font); --heading-Chinese-font: "#{$heading-Chinese-font}"; - } @else if $os == "linux" { + } @else if env.$os == "linux" { --heading-Latin-font: var(--base-Latin-font); --heading-Chinese-font: "#{$heading-Chinese-font}"; } @@ -127,7 +129,7 @@ --page-break-before-h2: auto; - @if $theme == "dark" { + @if env.$theme == "dark" { --md-char-color: hsl(212, 100%, 85%); --link-hover: hsl(212, 100%, 85%); --focus-cont-bg: hsl(0, 0%, 10%); diff --git a/src/scss/text.scss b/src/scss/text.scss index 80d335a..1db2d99 100644 --- a/src/scss/text.scss +++ b/src/scss/text.scss @@ -1,9 +1,11 @@ +@use "env"; + body { padding: 0 !important; margin: 0 !important; // line-height: var(--base-line-height); /* counter-reset: tableHead 0 imgHead 0; */ - @if $theme == "dark" { + @if env.$theme == "dark" { color: #dddddd; background-color: #1e1e1e; } @@ -29,9 +31,9 @@ body { font-size: var(--base-font-size); /* A4标准宽度 */ max-width: 21cm; - @if $theme == "light" { + @if env.$theme == "light" { background-color: white; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { background-color: #1e1e1e; } /* column-count: 2; @@ -52,11 +54,11 @@ body { } // 超链接 - @if $theme == "light" { + @if env.$theme == "light" { a { color: var(--link-color-light); } - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { a { color: var(--link-color-dark); } @@ -64,9 +66,9 @@ body { } hr { - @if $theme == "light" { + @if env.$theme == "light" { border-top: solid 1px #ddd; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { border-top: solid 1px #888888; } margin-top: 1.8em; diff --git a/src/scss/toc.scss b/src/scss/toc.scss index 8dc4684..d750b8e 100644 --- a/src/scss/toc.scss +++ b/src/scss/toc.scss @@ -1,3 +1,5 @@ +@use "env"; + /* 目录 */ .md-toc { font-size: var(--toc-font-size); @@ -10,16 +12,16 @@ } .md-toc-inner { margin-left: 0 !important; - @if $theme == "light" { + @if env.$theme == "light" { color: var(--text-color) !important; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { color: #dddddd !important; } } .md-toc-item { - @if $theme == "light" { + @if env.$theme == "light" { color: var(--text-color) !important; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { color: #dddddd !important; } } diff --git a/src/scss/typora.scss b/src/scss/typora.scss index 7a9d3d3..61576ba 100644 --- a/src/scss/typora.scss +++ b/src/scss/typora.scss @@ -1,12 +1,14 @@ +@use "env"; + @media screen { #write { padding: var(--set-margin); - @if $theme == "light" { + @if env.$theme == "light" { /* 添加一个淡蓝色的边框 */ /* border: 0.8px solid #AAC ; */ /* 页边阴影 */ box-shadow: 0 0 24px 12px #cccccc; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { /* border: 1px solid #AAAAAA ;*/ /* 页边阴影 */ box-shadow: 0 0 24px 12px #101010; @@ -21,7 +23,7 @@ /* typora 编写模式 */ #typora-source { - @if $theme == "dark" { + @if env.$theme == "dark" { /* background: ;*/ color: #dddddd; } @@ -72,7 +74,7 @@ /* 侧边栏的字体修改 */ font-family: var(--ui-font); list-style: none; - @if $theme == "dark" { + @if env.$theme == "dark" { /* 黑色模式修改 */ background-color: #282828; color: #e9e9e9; @@ -81,9 +83,9 @@ /* 元数据(如 YAML front matter)的背景框 */ pre.md-meta-block { - @if $theme == "light" { + @if env.$theme == "light" { background: #cccccc; - } @else if $theme == "dark" { + } @else if env.$theme == "dark" { background: #161616; color: white !important; } From 8237b52223d1ef65db10da81c4d6ccffe4f84f20 Mon Sep 17 00:00:00 2001 From: RalXYZ Date: Fri, 22 Nov 2024 23:37:27 +0800 Subject: [PATCH 2/4] fix: update ci yaml, add symbolic link from sass to dart-sass --- .github/workflows/dev-build.yml | 4 +++- .github/workflows/release.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index cb4bf08..93f35e9 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -25,10 +25,12 @@ jobs: extract: true - name: Add Binary to PATH run: | + ln -s "$GITHUB_WORKSPACE/dart-sass/sass" "$GITHUB_WORKSPACE/dart-sass/dart-sass" echo "$GITHUB_WORKSPACE/dart-sass" >> "$GITHUB_PATH" - name: Compile run: | - cd ./src; make -j3 + cd ./src + make -j3 - name: Upload Artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff475c1..0da64df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,12 @@ jobs: extract: true - name: Add Binary to PATH run: | + ln -s "$GITHUB_WORKSPACE/dart-sass/sass" "$GITHUB_WORKSPACE/dart-sass/dart-sass" echo "$GITHUB_WORKSPACE/dart-sass" >> "$GITHUB_PATH" - name: Compile run: | - cd ./src; make all-and-compress -j3 + cd ./src + make all-and-compress -j3 - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') From 013cc2cd4b6bbc5e1c45273727d6f0702798bf07 Mon Sep 17 00:00:00 2001 From: RalXYZ Date: Fri, 22 Nov 2024 23:48:49 +0800 Subject: [PATCH 3/4] fix: rm dev-build on push to dev/** --- .github/workflows/dev-build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 93f35e9..5a5390f 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -1,9 +1,6 @@ name: Dev Build on: - push: - branches: - - dev** pull_request: types: [opened, synchronize, reopened] From 990a4556e338149f1035145e0c3aa6c0a4c01450 Mon Sep 17 00:00:00 2001 From: RalXYZ Date: Sat, 23 Nov 2024 01:15:58 +0800 Subject: [PATCH 4/4] fix: fix broken variables --- src/Makefile | 5 +++-- src/headers/linux/dark.scss | 1 + src/headers/linux/light.scss | 1 + src/headers/macos/dark.scss | 1 + src/headers/macos/light.scss | 1 + src/headers/windows/dark.scss | 1 + src/headers/windows/light.scss | 1 + src/scss/blockquote.scss | 3 +++ src/scss/code.scss | 7 ++++--- src/scss/dark.scss | 5 +++-- src/scss/env.scss | 2 -- src/scss/footnote.scss | 3 +++ src/scss/heading.scss | 9 +++++---- src/scss/include.scss | 25 ++++++++++++++----------- src/scss/list.scss | 3 +++ src/scss/settings.scss | 17 +++++++++-------- src/scss/table.scss | 3 +++ src/scss/text.scss | 17 +++++++++-------- src/scss/toc.scss | 11 ++++++----- src/scss/typora.scss | 15 ++++++++------- 20 files changed, 79 insertions(+), 52 deletions(-) create mode 100644 src/headers/linux/dark.scss create mode 100644 src/headers/linux/light.scss create mode 100644 src/headers/macos/dark.scss create mode 100644 src/headers/macos/light.scss create mode 100644 src/headers/windows/dark.scss create mode 100644 src/headers/windows/light.scss delete mode 100644 src/scss/env.scss diff --git a/src/Makefile b/src/Makefile index 68fd4fb..0c87623 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,15 +12,16 @@ $(shell mkdir -p $(working_dir)) $(shell mkdir -p $(target_dir)) $(shell cp -r $(base_dir)/scss $(working_dir)/scss) +$(shell cp -r $(base_dir)/headers $(working_dir)/headers) # $(1) is the name of operating system, $(2) is typora or pandoc, $(3) is light or dark theme define build mkdir -p $(target_dir)/$(1)-$(2) mkdir -p $(target_dir)/$(1)-$(2)/target if [ "$(3)" = "light" ]; then \ - TYPORA_LATEX_THEME_BUILD_OS=$(1) TYPORA_LATEX_THEME_BUILD_THEME=$(3) dart-sass --no-source-map --style expanded $(working_dir)/scss/include.scss $(target_dir)/$(1)-$(2)/target/latex.css; \ + dart-sass --no-source-map --style expanded $(working_dir)/headers/$(1)/$(3).scss $(target_dir)/$(1)-$(2)/target/latex.css; \ else \ - TYPORA_LATEX_THEME_BUILD_OS=$(1) TYPORA_LATEX_THEME_BUILD_THEME=$(3) dart-sass --no-source-map --style expanded $(working_dir)/scss/include.scss $(target_dir)/$(1)-$(2)/target/latex-$(3).css; \ + dart-sass --no-source-map --style expanded $(working_dir)/headers/$(1)/$(3).scss $(target_dir)/$(1)-$(2)/target/latex-$(3).css; \ fi endef diff --git a/src/headers/linux/dark.scss b/src/headers/linux/dark.scss new file mode 100644 index 0000000..1df58c7 --- /dev/null +++ b/src/headers/linux/dark.scss @@ -0,0 +1 @@ +@use "../../scss/include.scss" with ($os: "linux", $theme: "dark"); diff --git a/src/headers/linux/light.scss b/src/headers/linux/light.scss new file mode 100644 index 0000000..ca8b168 --- /dev/null +++ b/src/headers/linux/light.scss @@ -0,0 +1 @@ +@use "../../scss/include.scss" with ($os: "linux", $theme: "light"); diff --git a/src/headers/macos/dark.scss b/src/headers/macos/dark.scss new file mode 100644 index 0000000..b3730c2 --- /dev/null +++ b/src/headers/macos/dark.scss @@ -0,0 +1 @@ +@use "../../scss/include.scss" with ($os: "macos", $theme: "dark"); diff --git a/src/headers/macos/light.scss b/src/headers/macos/light.scss new file mode 100644 index 0000000..2f6b2e4 --- /dev/null +++ b/src/headers/macos/light.scss @@ -0,0 +1 @@ +@use "../../scss/include.scss" with ($os: "macos", $theme: "light"); diff --git a/src/headers/windows/dark.scss b/src/headers/windows/dark.scss new file mode 100644 index 0000000..1ded830 --- /dev/null +++ b/src/headers/windows/dark.scss @@ -0,0 +1 @@ +@use "../../scss/include.scss" with ($os: "windows", $theme: "dark"); diff --git a/src/headers/windows/light.scss b/src/headers/windows/light.scss new file mode 100644 index 0000000..caa892d --- /dev/null +++ b/src/headers/windows/light.scss @@ -0,0 +1 @@ +@use "../../scss/include.scss" with ($os: "windows", $theme: "light"); diff --git a/src/scss/blockquote.scss b/src/scss/blockquote.scss index fbe4e4b..b1cfcb2 100644 --- a/src/scss/blockquote.scss +++ b/src/scss/blockquote.scss @@ -1,3 +1,6 @@ +$os: "" !default; +$theme: "" !default; + /* 一个>的引言仅为两字符缩进,使用>>的引言为传统引言样式,具有左竖线、左缩进 */ blockquote { diff --git a/src/scss/code.scss b/src/scss/code.scss index 0193576..1c23617 100644 --- a/src/scss/code.scss +++ b/src/scss/code.scss @@ -1,4 +1,5 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; /* 行内代码 */ code { @@ -7,12 +8,12 @@ code { h1 code, h2 code, h3 code, h4 code, h5 code, h6 code, p code, li code { - @if env.$theme == "light" { + @if $theme == "light" { color: rgb(60, 112, 198); background-color: #fefefe; /* 阴影 */ box-shadow: 0 0 1px 1px #c8d3df; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { /* 黑色模式修改 */ color: #8bb1f9; /* 黑色模式修改 */ diff --git a/src/scss/dark.scss b/src/scss/dark.scss index 0df6005..b2b4a03 100644 --- a/src/scss/dark.scss +++ b/src/scss/dark.scss @@ -1,6 +1,7 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; -@if env.$theme == "dark" { +@if $theme == "dark" { /* 可能的代码高亮样式 .cm-s-inner { background-color: #263238; diff --git a/src/scss/env.scss b/src/scss/env.scss deleted file mode 100644 index 1be5fd5..0000000 --- a/src/scss/env.scss +++ /dev/null @@ -1,2 +0,0 @@ -$os: env(TYPORA_LATEX_THEME_BUILD_OS); -$theme: env(TYPORA_LATEX_THEME_BUILD_THEME); diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index 995dae7..db41b6b 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -1,3 +1,6 @@ +$os: "" !default; +$theme: "" !default; + /* 参考文献(脚注)块 */ .footnotes { font-size: 0.95em; diff --git a/src/scss/heading.scss b/src/scss/heading.scss index 0455bce..793c6e1 100644 --- a/src/scss/heading.scss +++ b/src/scss/heading.scss @@ -1,4 +1,5 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; #write { // 标题属性 @@ -8,9 +9,9 @@ h4, h5, h6 { - @if env.$os == "windows" { + @if $os == "windows" { font-weight: bold; - } @else if env.$os == "macos" { + } @else if $os == "macos" { font-weight: normal; } break-after: avoid-page !important; @@ -18,7 +19,7 @@ h1 { font-family: var(--heading-Latin-font), var(--title-Chinese-font), serif; - @if env.$os == "macos" { + @if $os == "macos" { font-weight: normal; } text-align: center; diff --git a/src/scss/include.scss b/src/scss/include.scss index dc81a10..9c7408f 100644 --- a/src/scss/include.scss +++ b/src/scss/include.scss @@ -1,14 +1,17 @@ -@use "./settings.scss"; +$os: "" !default; +$theme: "" !default; -@use "./text.scss"; -@use "./typora.scss"; +@use "./settings.scss" with ($os: $os, $theme: $theme); -@use "./heading.scss"; -@use "./footnote.scss"; -@use "./list.scss"; -@use "./table.scss"; -@use "./blockquote.scss"; -@use "./code.scss"; -@use "./toc.scss"; +@use "./text.scss" with ($os: $os, $theme: $theme); +@use "./typora.scss" with ($os: $os, $theme: $theme); -@use "./dark.scss"; +@use "./heading.scss" with ($os: $os, $theme: $theme); +@use "./footnote.scss" with ($os: $os, $theme: $theme); +@use "./list.scss" with ($os: $os, $theme: $theme); +@use "./table.scss" with ($os: $os, $theme: $theme); +@use "./blockquote.scss" with ($os: $os, $theme: $theme); +@use "./code.scss" with ($os: $os, $theme: $theme); +@use "./toc.scss" with ($os: $os, $theme: $theme); + +@use "./dark.scss" with ($os: $os, $theme: $theme); diff --git a/src/scss/list.scss b/src/scss/list.scss index a2cc17e..76c145a 100644 --- a/src/scss/list.scss +++ b/src/scss/list.scss @@ -1,3 +1,6 @@ +$os: "" !default; +$theme: "" !default; + /* 无序列表 */ #write ul { list-style: disc; diff --git a/src/scss/settings.scss b/src/scss/settings.scss index 2735333..20d27ea 100644 --- a/src/scss/settings.scss +++ b/src/scss/settings.scss @@ -1,4 +1,5 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; :root { $ui-font: null; @@ -6,19 +7,19 @@ $chapter-Chinese-font: null; $sub-chapter-Chinese-font: null; $sub-sub-chapter-Chinese-font: null; - @if env.$os == "windows" { + @if $os == "windows" { $ui-font: "\"阿里巴巴普惠体 2.0\"", "\"微软雅黑\""; $heading-Chinese-font: "华文黑体"; $chapter-Chinese-font: "华文黑体"; $sub-chapter-Chinese-font: "华文楷体"; $sub-sub-chapter-Chinese-font: "华文仿宋"; - } @else if env.$os == "macos" { + } @else if $os == "macos" { $ui-font: "\"苹方-简\""; $heading-Chinese-font: "华文黑体Bold"; $chapter-Chinese-font: "方正公文黑体"; $sub-chapter-Chinese-font: "方正公文楷体"; $sub-sub-chapter-Chinese-font: "方正公文仿宋"; - } @else if env.$os == "linux" { + } @else if $os == "linux" { $ui-font: "\"Noto Sans CJK SC\""; $heading-Chinese-font: "Noto Sans CJK SC"; $chapter-Chinese-font: "Noto Sans CJK SC"; @@ -71,14 +72,14 @@ --table-font: ""; /* 标题字体(总设置) */ - @if env.$os == "macos" { + @if $os == "macos" { /* 注意,如果您使用macOS系统并更改了英文字体,请在此处更换标题英文字体粗体字重的postscript值 */ --heading-Latin-font: "LMRoman10-Bold"; --heading-Chinese-font: "#{$heading-Chinese-font}"; - } @else if env.$os == "windows" { + } @else if $os == "windows" { --heading-Latin-font: var(--base-Latin-font); --heading-Chinese-font: "#{$heading-Chinese-font}"; - } @else if env.$os == "linux" { + } @else if $os == "linux" { --heading-Latin-font: var(--base-Latin-font); --heading-Chinese-font: "#{$heading-Chinese-font}"; } @@ -129,7 +130,7 @@ --page-break-before-h2: auto; - @if env.$theme == "dark" { + @if $theme == "dark" { --md-char-color: hsl(212, 100%, 85%); --link-hover: hsl(212, 100%, 85%); --focus-cont-bg: hsl(0, 0%, 10%); diff --git a/src/scss/table.scss b/src/scss/table.scss index d9466b7..e9acd31 100644 --- a/src/scss/table.scss +++ b/src/scss/table.scss @@ -1,3 +1,6 @@ +$os: "" !default; +$theme: "" !default; + #write { // 三线表 table { diff --git a/src/scss/text.scss b/src/scss/text.scss index 1db2d99..548c02b 100644 --- a/src/scss/text.scss +++ b/src/scss/text.scss @@ -1,11 +1,12 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; body { padding: 0 !important; margin: 0 !important; // line-height: var(--base-line-height); /* counter-reset: tableHead 0 imgHead 0; */ - @if env.$theme == "dark" { + @if $theme == "dark" { color: #dddddd; background-color: #1e1e1e; } @@ -31,9 +32,9 @@ body { font-size: var(--base-font-size); /* A4标准宽度 */ max-width: 21cm; - @if env.$theme == "light" { + @if $theme == "light" { background-color: white; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { background-color: #1e1e1e; } /* column-count: 2; @@ -54,11 +55,11 @@ body { } // 超链接 - @if env.$theme == "light" { + @if $theme == "light" { a { color: var(--link-color-light); } - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { a { color: var(--link-color-dark); } @@ -66,9 +67,9 @@ body { } hr { - @if env.$theme == "light" { + @if $theme == "light" { border-top: solid 1px #ddd; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { border-top: solid 1px #888888; } margin-top: 1.8em; diff --git a/src/scss/toc.scss b/src/scss/toc.scss index d750b8e..692beba 100644 --- a/src/scss/toc.scss +++ b/src/scss/toc.scss @@ -1,4 +1,5 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; /* 目录 */ .md-toc { @@ -12,16 +13,16 @@ } .md-toc-inner { margin-left: 0 !important; - @if env.$theme == "light" { + @if $theme == "light" { color: var(--text-color) !important; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { color: #dddddd !important; } } .md-toc-item { - @if env.$theme == "light" { + @if $theme == "light" { color: var(--text-color) !important; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { color: #dddddd !important; } } diff --git a/src/scss/typora.scss b/src/scss/typora.scss index 61576ba..553021a 100644 --- a/src/scss/typora.scss +++ b/src/scss/typora.scss @@ -1,14 +1,15 @@ -@use "env"; +$os: "" !default; +$theme: "" !default; @media screen { #write { padding: var(--set-margin); - @if env.$theme == "light" { + @if $theme == "light" { /* 添加一个淡蓝色的边框 */ /* border: 0.8px solid #AAC ; */ /* 页边阴影 */ box-shadow: 0 0 24px 12px #cccccc; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { /* border: 1px solid #AAAAAA ;*/ /* 页边阴影 */ box-shadow: 0 0 24px 12px #101010; @@ -23,7 +24,7 @@ /* typora 编写模式 */ #typora-source { - @if env.$theme == "dark" { + @if $theme == "dark" { /* background: ;*/ color: #dddddd; } @@ -74,7 +75,7 @@ /* 侧边栏的字体修改 */ font-family: var(--ui-font); list-style: none; - @if env.$theme == "dark" { + @if $theme == "dark" { /* 黑色模式修改 */ background-color: #282828; color: #e9e9e9; @@ -83,9 +84,9 @@ /* 元数据(如 YAML front matter)的背景框 */ pre.md-meta-block { - @if env.$theme == "light" { + @if $theme == "light" { background: #cccccc; - } @else if env.$theme == "dark" { + } @else if $theme == "dark" { background: #161616; color: white !important; }