Skip to content

Commit

Permalink
add Joplin support (#56)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
stephanoskomnenos and RalXYZ authored Dec 8, 2021
1 parent e10f315 commit f9ef60d
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- dev**
pull_request:
types: [opened, synchronize, reopened]

jobs:
compile:
Expand Down
15 changes: 15 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ macos = macos
linux = linux
typora = typora
pandoc = pandoc
joplin = joplin

$(shell mkdir -p $(working_dir))
$(shell mkdir -p $(target_dir))
Expand Down Expand Up @@ -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:
Expand All @@ -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)
37 changes: 37 additions & 0 deletions src/install_joplin.ps1
Original file line number Diff line number Diff line change
@@ -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)
73 changes: 70 additions & 3 deletions src/latex-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ strong {
}

@media print {
@if $tool == "joplin" {
.exported-note-title {
display: none !important;
}
}
#write {
padding: 0 !important;
}
Expand All @@ -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" {
Expand All @@ -235,6 +247,11 @@ strong {
/* 这里可以试分栏的,但确实不适合实现 */

p {
@if $tool == "joplin" {
/* Joplin 编辑时不支持段首空格,若需要可在这里设置 */
/*text-indent: 2em;*/
font-size: var(--base-font-size);
}
text-align: left;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -310,25 +340,56 @@ 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;
}

thead {
/* 表格标题(首行)样式 */
/* 三线表表头的线 */
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);
}

Expand Down Expand Up @@ -435,6 +496,9 @@ img {

/* ============ 多级列表样式 ============ */
ul {
@if $tool == "joplin" {
font-size: var(--base-font-size);
}
/* 无序列表第一级:实心圆点 */
list-style: disc;
ul {
Expand All @@ -451,6 +515,9 @@ ul {
}

ol {
@if $tool == "joplin" {
font-size: var(--base-font-size);
}
/* 有序列表第一级:数字 */
list-style: decimal;

Expand Down

0 comments on commit f9ef60d

Please sign in to comment.