From f9ef60d5337574863e8a6c1441337944a9d37606 Mon Sep 17 00:00:00 2001 From: Stephanos Komnenos Date: Wed, 8 Dec 2021 19:31:13 +0800 Subject: [PATCH] add Joplin support (#56) * add Joplin support * fix: remove bottom-lines of h1, h2 * fix: fix typora support * chore: dev-build for pull request * revert files in Supplemental Co-authored-by: RalXYZ --- .github/workflows/dev-build.yml | 2 + src/Makefile | 15 +++++++ src/install_joplin.ps1 | 37 +++++++++++++++++ src/latex-theme.scss | 73 +++++++++++++++++++++++++++++++-- 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/install_joplin.ps1 diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 2d09464..550537e 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -4,6 +4,8 @@ on: push: branches: - dev** + pull_request: + types: [opened, synchronize, reopened] jobs: compile: diff --git a/src/Makefile b/src/Makefile index 7cdf734..3b74560 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,6 +7,7 @@ macos = macos linux = linux typora = typora pandoc = pandoc +joplin = joplin $(shell mkdir -p $(working_dir)) $(shell mkdir -p $(target_dir)) @@ -46,12 +47,20 @@ define build-pandoc $(call build,$(linux),$(pandoc),dark) endef +define build-joplin + $(call build,$(1),$(joplin),light) + if [ "$(1)" = "$(windows)" ]; then \ + cp $(base_dir)/install_joplin.ps1 $(target_dir)/$(1)-$(joplin); \ + fi; +endef + .PHONY: all all: make windows make macos make linux make pandoc + make joplin .PHONY: all-and-compress all-and-compress: @@ -77,6 +86,12 @@ linux: pandoc: $(call build-pandoc,$(linux)) +.PHONY: joplin +joplin: + $(call build-joplin,$(windows)) + $(call build-joplin,$(linux)) + $(call build-joplin,$(macos)) + .PHONY: clean clean: rm -rf $(target_dir) $(working_dir) diff --git a/src/install_joplin.ps1 b/src/install_joplin.ps1 new file mode 100644 index 0000000..93e2366 --- /dev/null +++ b/src/install_joplin.ps1 @@ -0,0 +1,37 @@ +# this file will be copied into target directory + +Add-Type -AssemblyName PresentationFramework + +$dir="$env:USERPROFILE\.config\joplin-desktop" + +Write-Output "正在寻找 Joplin 主题文件夹 $dir" +If (Test-Path -Path $dir -PathType Container) { + Write-Output "已找到该文件夹" +} Else { + $MessageBody = "未找到 Joplin 主题文件夹,请先安装 Joplin" + $ButtonType = [System.Windows.MessageBoxButton]::OK + $MessageIcon = [System.Windows.MessageBoxImage]::Error + $MessageTitle = "安装失败" + Write-Error $MessageBody + [System.Windows.MessageBox]::Show($MessageBody, $MessageTitle, $ButtonType, $MessageIcon) + Throw $MessageBody +} + +Try { + Copy-Item -Path ".\target\latex.css" -Destination "$dir\userstyle.css" -Recurse -Force -ErrorAction Stop +} Catch { + $MessageBody = $_.Exception.Message + $ButtonType = [System.Windows.MessageBoxButton]::OK + $MessageIcon = [System.Windows.MessageBoxImage]::Error + $MessageTitle = "安装失败" + Write-Error $MessageTitle + [System.Windows.MessageBox]::Show($MessageBody, $MessageTitle, $ButtonType, $MessageIcon) + Throw $MessageBody +} + +$MessageBody = "主题文件已安装成功" +$ButtonType = [System.Windows.MessageBoxButton]::OK +$MessageIcon = [System.Windows.MessageBoxImage]::Information +$MessageTitle = "安装成功" +Write-Output $MessageTitle +[System.Windows.MessageBox]::Show($MessageBody, $MessageTitle, $ButtonType, $MessageIcon) diff --git a/src/latex-theme.scss b/src/latex-theme.scss index dc72dd5..04e496a 100644 --- a/src/latex-theme.scss +++ b/src/latex-theme.scss @@ -194,6 +194,11 @@ strong { } @media print { + @if $tool == "joplin" { + .exported-note-title { + display: none !important; + } + } #write { padding: 0 !important; } @@ -215,11 +220,18 @@ strong { body { @extend %base; } +} @else if $tool == "joplin" { + body { + @extend %base; + } } %base { font-family: var(--base-Latin-font), var(--base-Chinese-font), serif; - font-size: var(--base-font-size); + @if $tool != "joplin" { + //缁熶竴璁剧疆瀛椾綋澶у皬浼氬鑷 Joplin 鍏紡鏄剧ず寮傚父锛屽湪 Joplin 閲岄渶瑕佸悇鑷缃 + font-size: var(--base-font-size); + } /* A4鏍囧噯瀹藉害 */ max-width: 21cm; @if $theme == "light" { @@ -235,6 +247,11 @@ strong { /* 杩欓噷鍙互璇曞垎鏍忕殑锛屼絾纭疄涓嶉傚悎瀹炵幇 */ p { + @if $tool == "joplin" { + /* Joplin 缂栬緫鏃朵笉鏀寔娈甸绌烘牸锛岃嫢闇瑕佸彲鍦ㄨ繖閲岃缃 */ + /*text-indent: 2em;*/ + font-size: var(--base-font-size); + } text-align: left; } @@ -256,6 +273,14 @@ strong { page-break-after: avoid !important; } + @if $tool == "joplin" { + h1, + h2 { + /* 鍘婚櫎涓銆佷簩绾ф爣棰樼殑涓嬪垝绾 */ + border-bottom: none; + } + } + h1 { font-family: var(--heading-Latin-font), var(--title-Chinese-font), sans-serif; @@ -298,9 +323,14 @@ strong { border-top: 1.2pt solid; /* 涓夌嚎琛ㄧ浜屾潯绾垮搴 */ border-bottom: 1.2pt solid; + @if $tool == "joplin" { + //鍘婚櫎宸﹀彸杈圭晫绾 + border-left: none; + border-right: none; + } font-family: var(--table-font), var(--base-Latin-font), var(--base-Chinese-font), serif; - /* font-size: var(--base-font-size); */ + font-size: var(--base-font-size); text-align: center; page-break-inside: avoid; border-spacing: 6px; @@ -310,15 +340,42 @@ strong { margin: 0 auto; td { + @if $tool == "joplin" { + font-family: inherit; + font-size: inherit; + text-align: inherit; + border: none; + } padding: 2px; } tr { + @if $tool == "joplin" { + font-family: inherit; + font-size: inherit; + text-align: inherit; + border: none; + background: none; + } padding: 2px; } + + @if $tool == "joplin" { + /* 鍘婚櫎绗2n琛岄粯璁ょ殑鑳屾櫙棰滆壊 */ + tr:nth-child(2n) { + background: none; + } + } } th { + @if $tool == "joplin" { + font-family: var(--table-font), var(--base-Latin-font), + var(--base-Chinese-font), serif; + font-size: var(--base-font-size); + text-align: center; + border: none; + } padding: 0px 6px; } @@ -326,9 +383,13 @@ strong { /* 琛ㄦ牸鏍囬锛堥琛岋級鏍峰紡 */ /* 涓夌嚎琛ㄨ〃澶寸殑绾 */ border-bottom: 0.5pt solid; + @if $tool == "joplin" { + font-size: var(--base-font-size); + background: none; + /* 鍘婚櫎鑳屾櫙棰滆壊 */ + } font-family: var(--table-title-font), var(--heading-Latin-font), var(--heading-Chinese-font), serif !important; - /* font-size: var(--base-font-size); */ font-weight: var(--strong-weight); } @@ -435,6 +496,9 @@ img { /* ============ 澶氱骇鍒楄〃鏍峰紡 ============ */ ul { + @if $tool == "joplin" { + font-size: var(--base-font-size); + } /* 鏃犲簭鍒楄〃绗竴绾э細瀹炲績鍦嗙偣 */ list-style: disc; ul { @@ -451,6 +515,9 @@ ul { } ol { + @if $tool == "joplin" { + font-size: var(--base-font-size); + } /* 鏈夊簭鍒楄〃绗竴绾э細鏁板瓧 */ list-style: decimal;