feat: refactor export system and improve PDF/email handling
Major improvements to PDF export functionality and code organization: - BREAKING: Refactor main.ts from 4224 to 994 lines by extracting modular components - Replace broken PDF links with proper Typst pdf.embed() attachments - Filter out unnecessary "Open:" links and Mail.app links from exports - Fix duplicate title issue by replacing frontmatter title with filename - Move temp file processing from system temp to plugin folder - Clean up temp-images and temp-pandoc directories after export - Remove timestamp from export filenames to match note names exactly - Handle Unicode line separators (0x2028, 0x2029) in email content - Improve markdown preprocessing with better frontmatter handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
20 files changed
+7166
-3936
No files matched your search
+10
-1
@@ -99,6 +99,7 @@
|
||||
// Set page layout with conditional height based on export format
|
||||
set page(
|
||||
paper: paper,
|
||||
orientation: orientation,
|
||||
margin: page-margin,
|
||||
..if export_format == "single-page" { (height: auto,) } else { (:) },
|
||||
numbering: pagenumbering,
|
||||
@@ -136,7 +137,7 @@
|
||||
)
|
||||
|
||||
// Magazine-style paragraphs
|
||||
set par(justify: true, leading: 0.7em, first-line-indent: 0.8em)
|
||||
set par(justify: false, leading: 0.7em, first-line-indent: 0.8em)
|
||||
|
||||
// No heading numbering for magazine style
|
||||
if sectionnumbering != none {
|
||||
@@ -182,6 +183,14 @@
|
||||
#it.body #h(0.5em) #line(length: 3cm, stroke: 1pt + rgb("#93c5fd"))
|
||||
]
|
||||
|
||||
// Apply monospace font to code blocks and inline code
|
||||
let code-font = if monospace_font != none and type(monospace_font) == str {
|
||||
(monospace_font, "Courier New", "Monaco")
|
||||
} else {
|
||||
("Courier New", "Monaco")
|
||||
}
|
||||
|
||||
show raw: set text(font: code-font)
|
||||
|
||||
// Decorative title block with background
|
||||
if title != none and title != "" [
|
||||
|
||||
+26
-17
@@ -2,38 +2,38 @@
|
||||
#let email-block(from: none, to: none, subject: none, date: none, body) = {
|
||||
block(
|
||||
width: 100%,
|
||||
inset: 6pt,
|
||||
stroke: 1pt + gray,
|
||||
inset: 16pt,
|
||||
stroke: 0.5pt + blue,
|
||||
radius: 5pt,
|
||||
breakable: true
|
||||
)[
|
||||
#grid(
|
||||
columns: (auto, 1fr),
|
||||
row-gutter: 3pt,
|
||||
row-gutter: 13pt,
|
||||
column-gutter: 8pt,
|
||||
if from != none [
|
||||
#text(style: "italic", size: 0.9em)[From:]
|
||||
#text(style: "italic", size: 1em)[From:]
|
||||
] else [],
|
||||
if from != none [
|
||||
#text(size: 0.9em)[#from]
|
||||
#text(size: 1em)[#from]
|
||||
] else [],
|
||||
if to != none [
|
||||
#text(style: "italic", size: 0.9em)[To:]
|
||||
#text(style: "italic", size: 1em)[To:]
|
||||
] else [],
|
||||
if to != none [
|
||||
#text(size: 0.9em)[#to]
|
||||
#text(size: 1em)[#to]
|
||||
] else [],
|
||||
if subject != none [
|
||||
#text(style: "italic", size: 0.9em)[Subject:]
|
||||
#text(style: "italic", size: 1em)[Subject:]
|
||||
] else [],
|
||||
if subject != none [
|
||||
#text(size: 0.9em)[#subject]
|
||||
#text(size: 1em)[#subject]
|
||||
] else [],
|
||||
if date != none [
|
||||
#text(style: "italic", size: 0.9em)[Date:]
|
||||
#text(style: "italic", size: 1em)[Date:]
|
||||
] else [],
|
||||
if date != none [
|
||||
#text(size: 0.9em)[#date]
|
||||
#text(size: 1em)[#date]
|
||||
] else [],
|
||||
)
|
||||
#if body != none [
|
||||
@@ -55,7 +55,7 @@
|
||||
lang: "en",
|
||||
region: "US",
|
||||
paper: "a4",
|
||||
margin: (x: 1.5cm, y: 1.5cm),
|
||||
margin: (x: 1.5cm, y: 1cm),
|
||||
cols: 1,
|
||||
font: ("Concourse OT 3", "Helvetica Neue", "Arial"),
|
||||
fontsize: 11pt,
|
||||
@@ -66,7 +66,7 @@
|
||||
monospace_font: none,
|
||||
heading_fontsize: none,
|
||||
small_fontsize: none,
|
||||
margin_top: none,
|
||||
margin_top: 9cm,
|
||||
margin_right: none,
|
||||
margin_bottom: none,
|
||||
margin_left: none,
|
||||
@@ -84,7 +84,7 @@
|
||||
// Use UI-configured margins if available, otherwise fall back to template defaults
|
||||
let page-margin = if margin_top != none {
|
||||
(
|
||||
top: if margin_top != none { margin_top } else { 1.5cm },
|
||||
top: if margin_top != none { margin_top } else { 9cm },
|
||||
right: if margin_right != none { margin_right } else { 1.5cm },
|
||||
bottom: if margin_bottom != none { margin_bottom } else { 1.5cm },
|
||||
left: if margin_left != none { margin_left } else { 1.5cm },
|
||||
@@ -97,7 +97,8 @@
|
||||
// Set page layout with conditional height based on export format
|
||||
set page(
|
||||
paper: paper,
|
||||
margin: page-margin,
|
||||
flipped: false,
|
||||
margin: (top: 2.5cm, right: 1.5cm, bottom: 2cm, left: 2.5cm),
|
||||
..if export_format == "single-page" { (height: auto,) } else { (:) },
|
||||
numbering: pagenumbering,
|
||||
header: context {
|
||||
@@ -125,7 +126,7 @@
|
||||
)
|
||||
|
||||
// Set paragraph properties - Clean spacing
|
||||
set par(justify: true, leading: 0.6em)
|
||||
set par(justify: false, leading: 0.6em)
|
||||
|
||||
// Set heading numbering
|
||||
if sectionnumbering != none {
|
||||
@@ -162,10 +163,18 @@
|
||||
#it
|
||||
]
|
||||
|
||||
// Apply monospace font to code blocks and inline code
|
||||
let code-font = if monospace_font != none and type(monospace_font) == str {
|
||||
(monospace_font, "Courier New", "Monaco")
|
||||
} else {
|
||||
("Courier New", "Monaco")
|
||||
}
|
||||
|
||||
show raw: set text(font: code-font)
|
||||
|
||||
// Title block - Clean and minimal
|
||||
if title != none and title != "" [
|
||||
#align(center, text(16pt, weight: "bold")[#title])
|
||||
#align(left, text(16pt, weight: "bold")[#title])
|
||||
#v(0.8em)
|
||||
]
|
||||
|
||||
|
||||
+17
-18
@@ -90,25 +90,16 @@
|
||||
} else {
|
||||
margin
|
||||
}
|
||||
|
||||
|
||||
// Set page layout with conditional height based on export format
|
||||
if export_format == "single-page" {
|
||||
set page(
|
||||
paper: paper,
|
||||
margin: page-margin,
|
||||
height: auto, // Auto height for continuous single page
|
||||
numbering: pagenumbering,
|
||||
fill: rgb("#fafafa")
|
||||
)
|
||||
} else {
|
||||
set page(
|
||||
paper: paper,
|
||||
margin: page-margin,
|
||||
// No height specified = uses default paper size height
|
||||
numbering: pagenumbering,
|
||||
fill: rgb("#fafafa")
|
||||
)
|
||||
}
|
||||
set page(
|
||||
paper: paper,
|
||||
orientation: orientation,
|
||||
margin: (top: 2.5cm, right: 1.5cm, bottom: 2cm, left: 2.5cm),
|
||||
..if export_format == "single-page" { (height: auto,) } else { (:) },
|
||||
numbering: pagenumbering,
|
||||
fill: rgb("#fafafa")
|
||||
)
|
||||
|
||||
// Modern sans-serif fonts
|
||||
// Use UI-configured font if available, otherwise use template default
|
||||
@@ -179,6 +170,14 @@
|
||||
#it.body
|
||||
]
|
||||
|
||||
// Apply monospace font to code blocks and inline code
|
||||
let code-font = if monospace_font != none and type(monospace_font) == str {
|
||||
(monospace_font, "Courier New", "Monaco")
|
||||
} else {
|
||||
("Courier New", "Monaco")
|
||||
}
|
||||
|
||||
show raw: set text(font: code-font)
|
||||
|
||||
// Modern title header with sidebar design
|
||||
if title != none and title != "" [
|
||||
|
||||
+16
-6
@@ -67,7 +67,7 @@
|
||||
paper: "a4",
|
||||
margin: (x: 3cm, y: 2.5cm),
|
||||
cols: 1,
|
||||
font: ("Concourse OT", "Helvetica Neue", "Arial", "sans-serif"),
|
||||
font: ("Concourse OT 3", "Helvetica Neue", "Arial"),
|
||||
fontsize: 11pt,
|
||||
sectionnumbering: "1.",
|
||||
pagenumbering: "1",
|
||||
@@ -105,6 +105,7 @@
|
||||
// Set page layout with conditional height based on export format
|
||||
set page(
|
||||
paper: paper,
|
||||
orientation: orientation,
|
||||
margin: page-margin,
|
||||
..if export_format == "single-page" { (height: auto,) } else { (:) },
|
||||
numbering: pagenumbering,
|
||||
@@ -139,7 +140,7 @@
|
||||
// Business document font
|
||||
// Use UI-configured font if available, otherwise use template default
|
||||
let body-font = if font != none and type(font) == str {
|
||||
(font, "Concourse OT", "Helvetica Neue", "Arial", "sans-serif")
|
||||
(font, "Concourse OT 3", "Helvetica Neue", "Arial")
|
||||
} else {
|
||||
font
|
||||
}
|
||||
@@ -153,8 +154,9 @@
|
||||
region: region
|
||||
)
|
||||
|
||||
// Professional paragraph formatting
|
||||
set par(justify: true, leading: 0.7em, first-line-indent: 0pt)
|
||||
// Professional paragraph formatting - use left alignment instead of full justification
|
||||
// Full justification can create ugly gaps in short lines and attachment text
|
||||
set par(justify: false, leading: 0.7em, first-line-indent: 0pt)
|
||||
|
||||
// Chapter-style numbering
|
||||
if sectionnumbering != none {
|
||||
@@ -172,7 +174,7 @@
|
||||
inset: 12pt,
|
||||
stroke: (left: 4pt + rgb("#1f2937")),
|
||||
)[
|
||||
#set text(font: ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif"), size: 18pt, weight: "bold", fill: rgb("#1f2937"))
|
||||
#set text(font: ("SF Pro Text", "Helvetica Neue", "Arial"), size: 18pt, weight: "bold", fill: rgb("#1f2937"))
|
||||
#grid(
|
||||
columns: (auto, 1fr),
|
||||
column-gutter: 12pt,
|
||||
@@ -189,7 +191,7 @@
|
||||
inset: (bottom: 6pt),
|
||||
stroke: (bottom: 1pt + rgb("#e5e7eb")),
|
||||
)[
|
||||
#set text(font: ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif"), size: 14pt, weight: "semibold", fill: rgb("#374151"))
|
||||
#set text(font: ("SF Pro Text", "Helvetica Neue", "Arial"), size: 14pt, weight: "semibold", fill: rgb("#374151"))
|
||||
#counter(heading).display()
|
||||
#h(0.8em)
|
||||
#it.body
|
||||
@@ -206,6 +208,14 @@
|
||||
#it.body
|
||||
]
|
||||
|
||||
// Apply monospace font to code blocks and inline code
|
||||
let code-font = if monospace_font != none and type(monospace_font) == str {
|
||||
(monospace_font, "Courier New", "Monaco")
|
||||
} else {
|
||||
("Courier New", "Monaco")
|
||||
}
|
||||
|
||||
show raw: set text(font: code-font)
|
||||
|
||||
// Professional title page
|
||||
if title != none and title != "" [
|
||||
|
||||
Reference in new issue
Block a user