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; }