diff --git a/esbuild.config.mjs b/esbuild.config.mjs index a5de8b8..de49aca 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -31,6 +31,7 @@ const context = await esbuild.context({ "@lezer/common", "@lezer/highlight", "@lezer/lr", + "sharp", ...builtins], format: "cjs", target: "es2018", diff --git a/main.ts b/main.ts index 549446e..3b2d988 100644 --- a/main.ts +++ b/main.ts @@ -335,6 +335,77 @@ if (this.pandocOptions.variables) { } } +// Add typography settings as template variables +const plugin = (this as any).plugin; +if (plugin && plugin.settings) { + const settings = plugin.settings; + + // Add typography variables + if (settings.typography) { + if (settings.typography.fonts) { + if (settings.typography.fonts.body) { + args.push('-V', `font="${settings.typography.fonts.body}"`); + } + if (settings.typography.fonts.heading) { + args.push('-V', `heading_font="${settings.typography.fonts.heading}"`); + } + if (settings.typography.fonts.monospace) { + args.push('-V', `monospace_font="${settings.typography.fonts.monospace}"`); + } + } + + if (settings.typography.fontSizes) { + if (settings.typography.fontSizes.body) { + args.push('-V', `fontsize=${settings.typography.fontSizes.body}pt`); + } + if (settings.typography.fontSizes.heading) { + args.push('-V', `heading_fontsize=${settings.typography.fontSizes.heading}pt`); + } + if (settings.typography.fontSizes.small) { + args.push('-V', `small_fontsize=${settings.typography.fontSizes.small}pt`); + } + } + } + + // Add page setup variables + if (settings.pageSetup) { + if (settings.pageSetup.size) { + args.push('-V', `paper=${settings.pageSetup.size}`); + } + if (settings.pageSetup.orientation) { + args.push('-V', `orientation=${settings.pageSetup.orientation}`); + } + + // Convert margin points to cm for Typst (1 point = 0.0352778 cm) + if (settings.pageSetup.margins) { + const margins = settings.pageSetup.margins; + if (margins.top !== undefined) { + const topCm = (margins.top * 0.0352778).toFixed(2); + args.push('-V', `margin_top=${topCm}cm`); + } + if (margins.right !== undefined) { + const rightCm = (margins.right * 0.0352778).toFixed(2); + args.push('-V', `margin_right=${rightCm}cm`); + } + if (margins.bottom !== undefined) { + const bottomCm = (margins.bottom * 0.0352778).toFixed(2); + args.push('-V', `margin_bottom=${bottomCm}cm`); + } + if (margins.left !== undefined) { + const leftCm = (margins.left * 0.0352778).toFixed(2); + args.push('-V', `margin_left=${leftCm}cm`); + } + } + } + + // Add export format variable + if (settings.exportDefaults) { + if (settings.exportDefaults.format) { + args.push('-V', `export_format=${settings.exportDefaults.format}`); + } + } +} + // Add Typst engine options if (this.typstSettings.engineOptions) { for (const option of this.typstSettings.engineOptions) { @@ -524,13 +595,6 @@ return new Promise((resolve) => { * generating high-quality PDFs with customizable styling. */ -/** Export mode options for different conversion approaches */ -enum ExportMode { - /** Typography-focused export optimizing for readability */ - Typography = 'typography', - /** Style-preserving export maintaining original formatting */ - StylePreserving = 'style-preserving' -} /** Export format options for output structure */ enum ExportFormat { @@ -568,8 +632,6 @@ interface ExportConfig { template?: string; /** Override default format */ format?: ExportFormat; - /** Override default mode */ - mode?: ExportMode; /** Override output folder */ outputFolder?: string; /** Template variables for this export */ @@ -598,8 +660,6 @@ interface obsidianTypstPDFExportSettings { template: string; /** Default export format */ format: ExportFormat; - /** Default export mode */ - mode: ExportMode; }; /** Typography settings */ @@ -658,15 +718,14 @@ const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = { exportDefaults: { template: 'default', - format: ExportFormat.Standard, - mode: ExportMode.Typography + format: ExportFormat.Standard }, typography: { fonts: { - body: 'Times New Roman', - heading: 'Arial', - monospace: 'Courier New' + body: 'Concourse OT', + heading: 'SF Pro Text', + monospace: 'UbuntuMono Nerd Font Mono' }, fontSizes: { body: 11, @@ -903,9 +962,6 @@ export default class obsidianTypstPDFExport extends Plugin { exportDefaults.format = data.exportDefaults.format; } - if (Object.values(ExportMode).includes(data.exportDefaults.mode)) { - exportDefaults.mode = data.exportDefaults.mode; - } if (Object.keys(exportDefaults).length > 0) { validated.exportDefaults = exportDefaults as any; @@ -2215,17 +2271,6 @@ class TypstPDFExportSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); })); - new Setting(containerEl) - .setName('Export mode') - .setDesc('Processing approach for document conversion') - .addDropdown(dropdown => dropdown - .addOption(ExportMode.Typography, 'Typography-focused (optimized readability)') - .addOption(ExportMode.StylePreserving, 'Style-preserving (maintain formatting)') - .setValue(this.plugin.settings.exportDefaults.mode) - .onChange(async (value) => { - this.plugin.settings.exportDefaults.mode = value as ExportMode; - await this.plugin.saveSettings(); - })); // Typography Section new Setting(containerEl) @@ -2540,7 +2585,6 @@ export class ExportConfigModal extends Modal { noteTitle, template: plugin.settings.exportDefaults.template, format: plugin.settings.exportDefaults.format, - mode: plugin.settings.exportDefaults.mode, outputFolder: plugin.settings.outputFolder, templateVariables: {}, availableTemplates: [], // Will be populated by TemplateManager @@ -2689,7 +2733,6 @@ export class ExportConfigModal extends Modal { this.progressContainer.style.display = 'none'; // Generate form sections - this.createExportModeSection(); this.createFormatSection(); this.createTemplateSection(); this.createOutputSection(); @@ -2702,27 +2745,6 @@ export class ExportConfigModal extends Modal { this.updatePreview(); } - /** - * Create export mode selection section - */ - private createExportModeSection(): void { - const section = this.formContainer.createDiv('export-section'); - section.createEl('h3', { text: 'Export Mode' }); - - new Setting(section) - .setName('Export mode') - .setDesc('Choose between typography-focused or style-preserving export') - .addDropdown(dropdown => { - dropdown - .addOption(ExportMode.Typography, 'Typography (optimized for readability)') - .addOption(ExportMode.StylePreserving, 'Style-preserving (maintains original formatting)') - .setValue(this.settings.mode || ExportMode.Typography) - .onChange(value => { - this.settings.mode = value as ExportMode; - this.updatePreview(); - }); - }); - } /** * Create format selection section @@ -3170,9 +3192,6 @@ export class ExportConfigModal extends Modal { // Configuration summary const configItems = this.configPreview.createDiv('config-items'); - configItems.createDiv('config-item').innerHTML = - `Mode: ${this.settings.mode === ExportMode.Typography ? 'Typography' : 'Style-preserving'}`; - configItems.createDiv('config-item').innerHTML = `Format: ${this.settings.format === ExportFormat.Standard ? 'Standard PDF' : 'Single-page PDF'}`; @@ -3235,10 +3254,6 @@ export class ExportConfigModal extends Modal { // In a real implementation, this could analyze content length let baseSize = 150; // Base size in KB - if (this.settings.mode === ExportMode.StylePreserving) { - baseSize *= 1.5; // Style-preserving adds overhead - } - if (this.settings.format === ExportFormat.SinglePage) { baseSize *= 1.2; // Single-page format may be larger } @@ -3470,9 +3485,6 @@ export class ExportConfigModal extends Modal { this.plugin.settings.exportDefaults.format = this.settings.format; } - if (this.settings.mode) { - this.plugin.settings.exportDefaults.mode = this.settings.mode; - } // Update output folder preference if (this.settings.outputFolder && this.settings.outputFolder !== this.plugin.settings.outputFolder) { @@ -3493,7 +3505,6 @@ export class ExportConfigModal extends Modal { config: { template: this.settings.template, format: this.settings.format, - mode: this.settings.mode, outputFolder: this.settings.outputFolder, templateVariables: { ...this.settings.templateVariables } } @@ -3541,9 +3552,6 @@ export class ExportConfigModal extends Modal { this.settings.format = config.format; } - if (config.mode) { - this.settings.mode = config.mode; - } if (config.outputFolder) { this.settings.outputFolder = config.outputFolder; @@ -3592,7 +3600,6 @@ export class ExportConfigModal extends Modal { this.settings.template = defaults.template; this.settings.format = defaults.format; - this.settings.mode = defaults.mode; this.settings.outputFolder = this.plugin.settings.outputFolder; this.settings.templateVariables = { title: this.settings.noteTitle, @@ -3613,7 +3620,6 @@ export class ExportConfigModal extends Modal { version: '1.0', template: this.settings.template, format: this.settings.format, - mode: this.settings.mode, templateVariables: this.settings.templateVariables, // Don't include outputFolder (local path) or notePath (specific to this instance) }; @@ -3642,9 +3648,6 @@ export class ExportConfigModal extends Modal { this.settings.format = importData.format; } - if (importData.mode && Object.values(ExportMode).includes(importData.mode)) { - this.settings.mode = importData.mode; - } if (importData.templateVariables) { this.settings.templateVariables = { @@ -4169,7 +4172,6 @@ export class ExportConfigModal extends Modal { const exportConfig: ExportConfig = { template: this.settings.template, format: this.settings.format, - mode: this.settings.mode, outputFolder: this.settings.outputFolder, templateVariables: this.settings.templateVariables }; diff --git a/templates/article.typ b/templates/article.typ index 31c518a..9bb27b5 100644 --- a/templates/article.typ +++ b/templates/article.typ @@ -1,3 +1,57 @@ +// Email block styling function +#let email-block(from: none, to: none, subject: none, date: none, body) = { + block( + width: 100%, + inset: 8pt, + fill: rgb("#f1f5f9"), + stroke: 1pt + rgb("#cbd5e1"), + radius: 6pt, + breakable: true + )[ + #grid( + columns: (auto, 1fr), + row-gutter: 4pt, + column-gutter: 12pt, + if from != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#64748b"))[From:] + ] else [], + if from != none [ + #text(size: 0.9em, weight: "medium")[#from] + ] else [], + if to != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#64748b"))[To:] + ] else [], + if to != none [ + #text(size: 0.9em, weight: "medium")[#to] + ] else [], + if subject != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#64748b"))[Subject:] + ] else [], + if subject != none [ + #text(size: 0.9em, weight: "semibold")[#subject] + ] else [], + if date != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#64748b"))[Date:] + ] else [], + if date != none [ + #text(size: 0.9em)[#date] + ] else [], + ) + #if body != none [ + #v(6pt) + #block( + width: 100%, + inset: (left: 8pt, top: 8pt, bottom: 4pt), + stroke: (left: 3pt + rgb("#3b82f6")), + fill: white, + radius: (right: 4pt), + )[ + #body + ] + ] + ] +} + #let conf( title: none, authors: (), @@ -5,85 +59,166 @@ lang: "en", region: "US", paper: "a4", - margin: (x: 2.5cm, y: 2cm), - cols: 1, - font: ("Times New Roman"), + margin: (x: 2cm, y: 2.5cm), + cols: 2, + font: ("Concourse OT", "Georgia", "Times New Roman", "serif"), fontsize: 11pt, - sectionnumbering: "1.", + sectionnumbering: none, pagenumbering: "1", + // Support for UI-configurable options + heading_font: none, + monospace_font: none, + heading_fontsize: none, + small_fontsize: none, + margin_top: none, + margin_right: none, + margin_bottom: none, + margin_left: none, + orientation: "portrait", + export_format: none, doc, ) = { // Set document properties set document( title: title - // Skip author in document metadata to avoid type issues ) - // Set page layout + // Magazine-style layout with header + // 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 { 2.5cm }, + right: if margin_right != none { margin_right } else { 2cm }, + bottom: if margin_bottom != none { margin_bottom } else { 2.5cm }, + left: if margin_left != none { margin_left } else { 2cm }, + ) + } else { + margin + } + set page( paper: paper, - margin: margin, - numbering: pagenumbering + margin: page-margin, + numbering: pagenumbering, + header: context { + if counter(page).get().first() > 1 [ + #line(length: 100%, stroke: 0.5pt + rgb("#2563eb")) + #v(-0.5em) + #grid( + columns: (1fr, auto, 1fr), + [], + text(9pt, fill: rgb("#2563eb"), style: "italic")[#title], + align(right)[#text(9pt)[#counter(page).display("1")]] + ) + #v(0.5em) + #line(length: 100%, stroke: 0.5pt + rgb("#2563eb")) + ] + } ) - // Set text properties + // Mixed fonts - serif body, sans-serif headings + // Use UI-configured font if available, otherwise use template default + let body-font = if font != none and type(font) == "string" { + (font, "Concourse OT", "Georgia", "Times New Roman", "serif") + } else { + font + } + + let body-fontsize = fontsize + set text( - font: font, - size: fontsize, + font: body-font, + size: body-fontsize, lang: lang, region: region ) - // Set paragraph properties - set par(justify: true, leading: 0.65em, first-line-indent: 1.2em) + // Magazine-style paragraphs + set par(justify: true, leading: 0.7em, first-line-indent: 0.8em) - // Set heading numbering + // No heading numbering for magazine style if sectionnumbering != none { set heading(numbering: sectionnumbering) } - // Custom heading styles for article + // Magazine-style heading styles + // Use UI-configured heading font and size if available + let heading-font = if heading_font != none and type(heading_font) == "string" { + (heading_font, "SF Pro Text", "Helvetica Neue", "Arial", "sans-serif") + } else if heading_font != none { + heading_font + } else { + ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif") + } + + let heading-fontsize = if heading_fontsize != none { heading_fontsize } else { 15pt } + show heading.where(level: 1): it => block( width: 100%, - below: 1.5em, - above: 2em, + below: 1.2em, + above: 1.8em, + fill: rgb("#f8fafc"), + inset: 8pt, + radius: 4pt, + stroke: 1pt + rgb("#e2e8f0"), )[ - #set align(center) - #set text(16pt, weight: "bold") - #it.body + #set align(left) + #set text(font: heading-font, size: heading-fontsize, weight: "bold", fill: rgb("#1e40af")) + #block( + width: 100%, + inset: (bottom: 4pt), + stroke: (bottom: 2pt + rgb("#3b82f6")), + )[#it.body] ] show heading.where(level: 2): it => block( width: 100%, - below: 1em, - above: 1.5em, + below: 0.8em, + above: 1.2em, )[ - #set text(13pt, weight: "bold") - #it + #set text(font: heading-font, size: heading-fontsize * 0.87, weight: "semibold", fill: rgb("#1e40af")) + #it.body #h(0.5em) #line(length: 3cm, stroke: 1pt + rgb("#93c5fd")) ] - // Title block + + // Decorative title block with background if title != none and title != "" [ - #align(center, text(20pt, weight: "bold")[#title]) - #v(1em) + #block( + width: 100%, + fill: gradient.linear(rgb("#1e40af"), rgb("#3b82f6")), + inset: 16pt, + radius: 8pt, + )[ + #align(center, text(22pt, weight: "bold", fill: white)[#title]) + ] + #v(1.2em) ] - // Authors (handle Pandoc author structure) + // Authors in magazine style if authors != () and authors != none [ - #align(center, text(14pt)[ - #for author in authors [ + #align(center, text( + font: ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif"), + 13pt, + style: "italic", + fill: rgb("#64748b") + )[ + By #for author in authors [ #if author.name != none and author.name != "" [#author.name] ] ]) - #v(0.5em) + #v(0.6em) ] - // Date + // Date with styling if date != none [ - #align(center, text(12pt)[#date]) - #v(2em) + #align(center, text( + 10pt, + style: "italic", + fill: rgb("#64748b") + )[#date]) + #v(1.8em) ] - // Document content - doc + // Two-column layout for content + columns(cols, gutter: 1.2em)[#doc] } \ No newline at end of file diff --git a/templates/default.typ b/templates/default.typ index 8705be2..72553e1 100644 --- a/templates/default.typ +++ b/templates/default.typ @@ -1,3 +1,53 @@ +// Email block styling function +#let email-block(from: none, to: none, subject: none, date: none, body) = { + block( + width: 100%, + inset: 6pt, + stroke: 1pt + gray, + radius: 5pt, + breakable: true + )[ + #grid( + columns: (auto, 1fr), + row-gutter: 3pt, + column-gutter: 8pt, + if from != none [ + #text(style: "italic", size: 0.9em)[From:] + ] else [], + if from != none [ + #text(size: 0.9em)[#from] + ] else [], + if to != none [ + #text(style: "italic", size: 0.9em)[To:] + ] else [], + if to != none [ + #text(size: 0.9em)[#to] + ] else [], + if subject != none [ + #text(style: "italic", size: 0.9em)[Subject:] + ] else [], + if subject != none [ + #text(size: 0.9em)[#subject] + ] else [], + if date != none [ + #text(style: "italic", size: 0.9em)[Date:] + ] else [], + if date != none [ + #text(size: 0.9em)[#date] + ] else [], + ) + #if body != none [ + #block( + width: 100%, + inset: (left: 5pt, top: 6pt), + stroke: (left: 2pt + gray), + )[ + #body + ] + ] + ] +} + #let conf( title: none, authors: (), @@ -5,12 +55,23 @@ lang: "en", region: "US", paper: "a4", - margin: (x: 2.5cm, y: 2cm), + margin: (x: 1.5cm, y: 1.5cm), cols: 1, - font: ("Times New Roman"), - fontsize: 12pt, + font: ("Concourse OT", "Helvetica Neue", "Arial", "sans-serif"), + fontsize: 11pt, sectionnumbering: "1.", pagenumbering: "1", + // Support for UI-configurable options + heading_font: none, + monospace_font: none, + heading_fontsize: none, + small_fontsize: none, + margin_top: none, + margin_right: none, + margin_bottom: none, + margin_left: none, + orientation: "portrait", + export_format: none, doc, ) = { // Set document properties @@ -19,49 +80,106 @@ // Skip author in document metadata to avoid type issues ) - // Set page layout + // Set page layout - Clean minimal style + // 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 }, + 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 }, + ) + } else { + margin + } + set page( paper: paper, - margin: margin, - numbering: pagenumbering + margin: page-margin, + numbering: pagenumbering, + header: context { + if counter(page).get().first() > 1 [ + #h(1fr) #counter(page).display("1") + ] + } ) - // Set text properties + // Set text properties - Sans-serif for clean look + // Use UI-configured font if available, otherwise use template default + let body-font = if font != none and type(font) == "string" { + (font, "Concourse OT", "Helvetica Neue", "Arial", "sans-serif") + } else { + font + } + + let body-fontsize = fontsize + set text( - font: font, - size: fontsize, + font: body-font, + size: body-fontsize, lang: lang, region: region ) - // Set paragraph properties - set par(justify: true, leading: 0.65em) + // Set paragraph properties - Clean spacing + set par(justify: true, leading: 0.6em) // Set heading numbering if sectionnumbering != none { set heading(numbering: sectionnumbering) } - // Title block - if title != none and title != "" [ - #align(center, text(18pt, weight: "bold")[#title]) - #v(1em) + // Clean heading styles + // Use UI-configured heading font and size if available + let heading-font = if heading_font != none and type(heading_font) == "string" { + (heading_font, "SF Pro Text", "Helvetica Neue", "Arial", "sans-serif") + } else if heading_font != none { + heading_font + } else { + ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif") + } + + let heading-fontsize = if heading_fontsize != none { heading_fontsize } else { 14pt } + + show heading.where(level: 1): it => block( + width: 100%, + below: 1em, + above: 1.5em, + )[ + #set text(font: heading-font, size: heading-fontsize, weight: "bold") + #it ] - // Authors (handle Pandoc author structure) + show heading.where(level: 2): it => block( + width: 100%, + below: 0.8em, + above: 1.2em, + )[ + #set text(font: heading-font, size: heading-fontsize * 0.85, weight: "semibold") + #it + ] + + + // Title block - Clean and minimal + if title != none and title != "" [ + #align(center, text(16pt, weight: "bold")[#title]) + #v(0.8em) + ] + + // Authors - Simple layout if authors != () and authors != none [ - #align(center, text(14pt)[ + #align(center, text(11pt)[ #for author in authors [ #if author.name != none and author.name != "" [#author.name] ] ]) - #v(0.5em) + #v(0.4em) ] - // Date + // Date - Understated if date != none [ - #align(center, text(12pt)[#date]) - #v(2em) + #align(center, text(10pt, style: "italic")[#date]) + #v(1.5em) ] // Document content diff --git a/templates/report.typ b/templates/report.typ index 51a36de..15d1727 100644 --- a/templates/report.typ +++ b/templates/report.typ @@ -1,3 +1,63 @@ +// Email block styling function +#let email-block(from: none, to: none, subject: none, date: none, body) = { + block( + width: 100%, + inset: 10pt, + fill: rgb("#f8f9fa"), + stroke: 1pt + rgb("#dee2e6"), + radius: 4pt, + breakable: true + )[ + #text(size: 0.9em, weight: "semibold", fill: rgb("#495057"))[Email Communication] + #v(0.3em) + #line(length: 100%, stroke: 0.5pt + rgb("#adb5bd")) + #v(0.5em) + #grid( + columns: (auto, 1fr), + row-gutter: 4pt, + column-gutter: 16pt, + if from != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#6c757d"), weight: "medium")[From:] + ] else [], + if from != none [ + #text(size: 0.9em)[#from] + ] else [], + if to != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#6c757d"), weight: "medium")[To:] + ] else [], + if to != none [ + #text(size: 0.9em)[#to] + ] else [], + if subject != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#6c757d"), weight: "medium")[Subject:] + ] else [], + if subject != none [ + #text(size: 0.9em, weight: "medium")[#subject] + ] else [], + if date != none [ + #text(style: "italic", size: 0.85em, fill: rgb("#6c757d"), weight: "medium")[Date:] + ] else [], + if date != none [ + #text(size: 0.9em)[#date] + ] else [], + ) + #if body != none [ + #v(0.5em) + #line(length: 100%, stroke: 0.5pt + rgb("#adb5bd")) + #v(0.5em) + #block( + width: 100%, + inset: 8pt, + fill: white, + stroke: 1pt + rgb("#e9ecef"), + radius: 3pt, + )[ + #body + ] + ] + ] +} + #let conf( title: none, authors: (), @@ -5,94 +65,233 @@ lang: "en", region: "US", paper: "a4", - margin: (x: 2.5cm, y: 2.5cm), + margin: (x: 3cm, y: 2.5cm), cols: 1, - font: ("Times New Roman"), - fontsize: 12pt, + font: ("Concourse OT", "Helvetica Neue", "Arial", "sans-serif"), + fontsize: 11pt, sectionnumbering: "1.", pagenumbering: "1", + // Support for UI-configurable options + heading_font: none, + monospace_font: none, + heading_fontsize: none, + small_fontsize: none, + margin_top: none, + margin_right: none, + margin_bottom: none, + margin_left: none, + orientation: "portrait", + export_format: none, doc, ) = { // Set document properties set document( title: title - // Skip author in document metadata to avoid type issues ) - // Set page layout with header + // Professional report layout with wider margins for binding + // 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 { 2.5cm }, + right: if margin_right != none { margin_right } else { 3cm }, + bottom: if margin_bottom != none { margin_bottom } else { 2.5cm }, + left: if margin_left != none { margin_left } else { 3cm }, + ) + } else { + margin + } + set page( paper: paper, - margin: margin, + margin: page-margin, numbering: pagenumbering, header: context { - if counter(page).get().first() > 1 [ - #align(right, title) - #line(length: 100%) + let page-num = counter(page).get().first() + if page-num > 2 [ + #grid( + columns: (1fr, auto, 1fr), + text(9pt, style: "italic", fill: rgb("#4b5563"))[#title], + text(9pt, weight: "medium")[Chapter #counter(heading).display("1")], + align(right)[#text(9pt)[Page #page-num]] + ) + #v(-0.3em) + #line(length: 100%, stroke: 0.5pt + rgb("#d1d5db")) + ] + }, + footer: context { + let page-num = counter(page).get().first() + if page-num > 2 [ + #line(length: 100%, stroke: 0.5pt + rgb("#d1d5db")) + #v(0.2em) + #grid( + columns: (1fr, auto, 1fr), + text(8pt, fill: rgb("#6b7280"))[Document Date: #date], + [], + align(right)[#text(8pt, fill: rgb("#6b7280"))[Confidential]] + ) ] } ) - // Set text properties + // Business document font + // Use UI-configured font if available, otherwise use template default + let body-font = if font != none and type(font) == "string" { + (font, "Concourse OT", "Helvetica Neue", "Arial", "sans-serif") + } else { + font + } + + let body-fontsize = fontsize + set text( - font: font, - size: fontsize, + font: body-font, + size: body-fontsize, lang: lang, region: region ) - // Set paragraph properties - set par(justify: true, leading: 0.65em) + // Professional paragraph formatting + set par(justify: true, leading: 0.7em, first-line-indent: 0pt) - // Set heading numbering + // Chapter-style numbering if sectionnumbering != none { set heading(numbering: sectionnumbering) } - // Custom heading styles - show heading.where(level: 1): it => pagebreak(weak: true) + block( + // Professional report heading styles + show heading.where(level: 1): it => { + pagebreak(weak: true) + block( + width: 100%, + below: 2.5em, + above: 0pt, + fill: rgb("#f9fafb"), + 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")) + #grid( + columns: (auto, 1fr), + column-gutter: 12pt, + text(24pt, weight: "bold", fill: rgb("#4b5563"))[#counter(heading).display()], + align(horizon)[#it.body] + ) + ] + } + + show heading.where(level: 2): it => block( width: 100%, - below: 2em, - above: 0pt, + below: 1.2em, + above: 2em, + inset: (bottom: 6pt), + stroke: (bottom: 1pt + rgb("#e5e7eb")), )[ - #set align(center) - #set text(18pt, weight: "bold") + #set text(font: ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif"), size: 14pt, weight: "semibold", fill: rgb("#374151")) + #counter(heading).display() + #h(0.8em) + #it.body + ] + + show heading.where(level: 3): it => block( + width: 100%, + below: 0.8em, + above: 1.5em, + )[ + #set text(size: 12pt, weight: "medium", fill: rgb("#4b5563")) #counter(heading).display() #h(0.5em) #it.body ] - show heading.where(level: 2): it => block( - width: 100%, - below: 1em, - above: 1.5em, - )[ - #set text(14pt, weight: "bold") - #it - ] - // Title page + // Professional title page if title != none and title != "" [ page()[ + // Company header area + #block( + width: 100%, + inset: 12pt, + stroke: (bottom: 2pt + rgb("#1f2937")), + )[ + #align(right)[ + #text(8pt, fill: rgb("#6b7280"))[CONFIDENTIAL BUSINESS DOCUMENT] + ] + ] + #align(center + horizon)[ - #text(24pt, weight: "bold")[#title] - #v(2em) + #v(3em) + // Main title + #block( + width: 100%, + inset: 20pt, + fill: rgb("#f9fafb"), + stroke: 1pt + rgb("#e5e7eb"), + radius: 8pt, + )[ + #align(center)[ + #text(28pt, weight: "bold", fill: rgb("#1f2937"))[#title] + ] + ] + + #v(3em) + + // Authors/Prepared by #if authors != () and authors != none [ - #text(16pt)[ - #for author in authors [ - #if author.name != none and author.name != "" [#author.name] + #text(14pt, fill: rgb("#4b5563"))[Prepared by:] + #v(0.5em) + #for author in authors [ + #if author.name != none and author.name != "" [ + #text(18pt, weight: "medium")[#author.name] + #v(0.3em) ] ] - #v(1em) + #v(2em) ] + // Date #if date != none [ - #text(14pt)[#date] + #text(12pt, fill: rgb("#6b7280"))[Report Date:] + #v(0.3em) + #text(16pt, weight: "medium")[#date] ] + + #v(4em) + ] + + // Footer with document info + #place( + bottom, + block( + width: 100%, + inset: 12pt, + stroke: (top: 1pt + rgb("#e5e7eb")), + )[ + #text(8pt, fill: rgb("#9ca3af"))[ + This document contains confidential and proprietary information. + Distribution is restricted to authorized personnel only. + ] + ] + ) + ] + + // Table of contents page + pagebreak() + page()[ + #align(center)[ + #text(20pt, weight: "bold")[Table of Contents] + ] + #v(2em) + + // Note: Actual TOC would be generated by outline() in real use + #text(10pt, style: "italic", fill: rgb("#6b7280"))[ + Table of contents will be automatically generated based on document headings. ] ] ] - // Document content + // Document content starts on page 3 + pagebreak() doc } \ No newline at end of file diff --git a/templates/single-page.typ b/templates/single-page.typ index 506545c..f6aeb38 100644 --- a/templates/single-page.typ +++ b/templates/single-page.typ @@ -1,3 +1,52 @@ +// Email block styling function - compact for single page +#let email-block(from: none, to: none, subject: none, date: none, body) = { + block( + width: 100%, + inset: 8pt, + fill: white, + stroke: 1pt + rgb("#e5e7eb"), + radius: 4pt, + breakable: true + )[ + #text(size: 0.8em, weight: "semibold", fill: rgb("#374151"))[Email] + #v(0.2em) + #grid( + columns: (auto, 1fr), + row-gutter: 2pt, + column-gutter: 8pt, + if from != none [ + #text(style: "italic", size: 0.8em, fill: rgb("#6b7280"))[From:] + ] else [], + if from != none [ + #text(size: 0.8em)[#from] + ] else [], + if to != none [ + #text(style: "italic", size: 0.8em, fill: rgb("#6b7280"))[To:] + ] else [], + if to != none [ + #text(size: 0.8em)[#to] + ] else [], + if subject != none [ + #text(style: "italic", size: 0.8em, fill: rgb("#6b7280"))[Subject:] + ] else [], + if subject != none [ + #text(size: 0.8em, weight: "medium")[#subject] + ] else [], + ) + #if body != none [ + #v(0.3em) + #block( + width: 100%, + inset: 4pt, + fill: rgb("#f8f9fa"), + radius: 2pt, + )[ + #text(size: 0.8em)[#body] + ] + ] + ] +} + #let conf( title: none, authors: (), @@ -5,83 +54,189 @@ lang: "en", region: "US", paper: "a4", - margin: (x: 2.5cm, y: 2cm), + margin: (x: 1.8cm, y: 1.5cm), cols: 1, - font: ("Concourse OT"), - fontsize: 12pt, - sectionnumbering: "1.", + font: ("Concourse OT", "Helvetica Neue", "Arial", "sans-serif"), + fontsize: 10pt, + sectionnumbering: none, pagenumbering: none, // Single page doesn't need page numbers + // Support for UI-configurable options + heading_font: none, + monospace_font: none, + heading_fontsize: none, + small_fontsize: none, + margin_top: none, + margin_right: none, + margin_bottom: none, + margin_left: none, + orientation: "portrait", + export_format: none, doc, ) = { // Set document properties set document( title: title - // Skip author in document metadata to avoid type issues ) - // Set page layout - single page with auto height + // Modern single page layout with auto height + // 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 }, + right: if margin_right != none { margin_right } else { 1.8cm }, + bottom: if margin_bottom != none { margin_bottom } else { 1.5cm }, + left: if margin_left != none { margin_left } else { 1.8cm }, + ) + } else { + margin + } + set page( paper: paper, - margin: margin, + margin: page-margin, height: auto, - numbering: pagenumbering + numbering: pagenumbering, + fill: rgb("#fafafa") ) - // Set text properties + // Modern sans-serif fonts + // Use UI-configured font if available, otherwise use template default + let body-font = if font != none and type(font) == "string" { + (font, "Concourse OT", "Helvetica Neue", "Arial", "sans-serif") + } else { + font + } + + let body-fontsize = fontsize + set text( - font: font, - size: fontsize, + font: body-font, + size: body-fontsize, lang: lang, region: region ) - // Set paragraph properties - set par(justify: true, leading: 0.65em) + // Tight paragraph spacing for CV style + set par(justify: false, leading: 0.5em) - // Set heading numbering + // No section numbering for modern look if sectionnumbering != none { set heading(numbering: sectionnumbering) } - // Custom heading styles for single page + // Modern heading styles with color accents + // Use UI-configured heading font and size if available + let heading-font = if heading_font != none and type(heading_font) == "string" { + (heading_font, "SF Pro Text", "Helvetica Neue", "Arial", "sans-serif") + } else if heading_font != none { + heading_font + } else { + ("SF Pro Text", "Helvetica Neue", "Arial", "sans-serif") + } + + let heading-fontsize = if heading_fontsize != none { heading_fontsize } else { 13pt } + show heading.where(level: 1): it => block( width: 100%, - below: 1.5em, - above: 1.5em, + below: 1em, + above: 1.2em, + fill: rgb("#2563eb"), + inset: (x: 12pt, y: 8pt), + radius: 6pt, )[ - #set text(16pt, weight: "bold") - #it + #set text(font: heading-font, size: heading-fontsize, weight: "bold", fill: white) + #upper[#it.body] ] show heading.where(level: 2): it => block( width: 100%, - below: 1em, + below: 0.6em, above: 1em, + inset: (bottom: 3pt), + stroke: (bottom: 2pt + rgb("#2563eb")), )[ - #set text(14pt, weight: "bold") - #it + #set text(font: heading-font, size: heading-fontsize * 0.85, weight: "semibold", fill: rgb("#1e40af")) + #it.body ] - // Title block (inline, not separate page) + show heading.where(level: 3): it => block( + width: 100%, + below: 0.4em, + above: 0.8em, + )[ + #set text(size: 10pt, weight: "medium", fill: rgb("#374151")) + #it.body + ] + + + // Modern title header with sidebar design if title != none and title != "" [ - #align(center, text(18pt, weight: "bold")[#title]) + #block( + width: 100%, + fill: gradient.linear(rgb("#1e40af"), rgb("#3b82f6"), angle: 45deg), + inset: 16pt, + radius: (top: 8pt), + )[ + #grid( + columns: (2fr, 1fr), + column-gutter: 16pt, + // Main title area + [ + #text(24pt, weight: "bold", fill: white)[#title] + #if authors != () and authors != none [ + #v(0.3em) + #for author in authors [ + #if author.name != none and author.name != "" [ + #text(14pt, fill: rgb("#dbeafe"))[#author.name] + ] + ] + ] + ], + // Contact info sidebar + align(right + top)[ + #if date != none [ + #text(11pt, fill: rgb("#dbeafe"), style: "italic")[#date] + ] + ] + ) + ] #v(1em) - ] - - if authors != () and authors != none [ - #align(center, text(14pt)[ - #for author in authors [ - #if author.name != none and author.name != "" [#author.name] + ] else [ + // If no title, still show authors and date in a header + #if authors != () and authors != none or date != none [ + #block( + width: 100%, + fill: rgb("#f1f5f9"), + inset: 12pt, + radius: 6pt, + stroke: 1pt + rgb("#e2e8f0"), + )[ + #grid( + columns: (1fr, auto), + if authors != () and authors != none [ + #for author in authors [ + #if author.name != none and author.name != "" [ + #text(14pt, weight: "semibold", fill: rgb("#1e40af"))[#author.name] + ] + ] + ] else [], + if date != none [ + #text(10pt, style: "italic", fill: rgb("#64748b"))[#date] + ] else [] + ) ] - ]) - #v(0.5em) + #v(1em) + ] ] - if date != none [ - #align(center, text(12pt)[#date]) - #v(2em) + // Document content in a clean container + block( + width: 100%, + fill: white, + inset: 16pt, + radius: (bottom: 8pt), + stroke: 1pt + rgb("#e5e7eb"), + )[ + #doc ] - - // Document content - doc } \ No newline at end of file