Skip to content

Commit

Permalink
fix: update dart-sass to 1.81.0, enhance makefile performance
Browse files Browse the repository at this point in the history
use @use instead of @import
update dart-sass to 1.81.0
modify the makefile to enable more efficient concurrent builds
  • Loading branch information
RalXYZ committed Nov 22, 2024
1 parent 3fd0faf commit a3b4a53
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 80 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [opened, synchronize, reopened]

env:
DART_SASS_VERSION: 1.79.6
DART_SASS_VERSION: 1.81.0

jobs:
compile:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- v*

env:
DART_SASS_VERSION: 1.79.6
DART_SASS_VERSION: 1.81.0

jobs:
release:
Expand All @@ -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/')
Expand Down
15 changes: 4 additions & 11 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions src/headers/linux/dark.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/headers/linux/light.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/headers/macos/dark.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/headers/macos/light.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/headers/windows/dark.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/headers/windows/light.scss

This file was deleted.

6 changes: 4 additions & 2 deletions src/scss/code.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
@use "env";

/* 行内代码 */
code {
font-family: var(--code-font), var(--ui-font), monospace;
}
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;
/* 黑色模式修改 */
Expand Down
4 changes: 3 additions & 1 deletion src/scss/dark.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@if $theme == "dark" {
@use "env";

@if env.$theme == "dark" {
/* 可能的代码高亮样式
.cm-s-inner {
background-color: #263238;
Expand Down
2 changes: 2 additions & 0 deletions src/scss/env.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$os: env(TYPORA_LATEX_THEME_BUILD_OS);
$theme: env(TYPORA_LATEX_THEME_BUILD_THEME);
8 changes: 5 additions & 3 deletions src/scss/heading.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "env";

#write {
// 标题属性
h1,
Expand All @@ -6,17 +8,17 @@
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;
}

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;
Expand Down
22 changes: 11 additions & 11 deletions src/scss/include.scss
Original file line number Diff line number Diff line change
@@ -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";
16 changes: 9 additions & 7 deletions src/scss/settings.scss
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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}";
}
Expand Down Expand Up @@ -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%);
Expand Down
16 changes: 9 additions & 7 deletions src/scss/text.scss
Original file line number Diff line number Diff line change
@@ -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;
}
Expand All @@ -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;
Expand All @@ -52,21 +54,21 @@ 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);
}
}
}

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;
Expand Down
10 changes: 6 additions & 4 deletions src/scss/toc.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use "env";

/* 目录 */
.md-toc {
font-size: var(--toc-font-size);
Expand All @@ -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;
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/scss/typora.scss
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +23,7 @@

/* typora 编写模式 */
#typora-source {
@if $theme == "dark" {
@if env.$theme == "dark" {
/* background: ;*/
color: #dddddd;
}
Expand Down Expand Up @@ -72,7 +74,7 @@
/* 侧边栏的字体修改 */
font-family: var(--ui-font);
list-style: none;
@if $theme == "dark" {
@if env.$theme == "dark" {
/* 黑色模式修改 */
background-color: #282828;
color: #e9e9e9;
Expand All @@ -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;
}
Expand Down

0 comments on commit a3b4a53

Please sign in to comment.