mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
Update version to 1.3.3 and add font size adjustment features
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(git checkout:*)",
|
||||||
|
"Bash(npm install)",
|
||||||
|
"Bash(npm run build:*)",
|
||||||
|
"Bash(rmdir:*)",
|
||||||
|
"Bash(powershell:*)",
|
||||||
|
"Bash(npx electron-builder:*)",
|
||||||
|
"Bash(dir dist)",
|
||||||
|
"Bash(git tag:*)",
|
||||||
|
"Bash(git push:*)",
|
||||||
|
"Bash(gh release create:*)",
|
||||||
|
"Bash(gh auth:*)",
|
||||||
|
"Bash(gh release delete:*)",
|
||||||
|
"Bash(gh release list:*)",
|
||||||
|
"Bash(gh release upload:*)",
|
||||||
|
"Bash(npm install:*)",
|
||||||
|
"Bash(npm uninstall:*)",
|
||||||
|
"Bash(git add:*)"
|
||||||
|
],
|
||||||
|
"deny": []
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pan-converter",
|
"name": "pan-converter",
|
||||||
"version": "1.3.4",
|
"version": "1.3.6",
|
||||||
"description": "Cross-platform Markdown editor and converter using Pandoc",
|
"description": "Cross-platform Markdown editor and converter using Pandoc",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
"electron-store": "^10.1.0",
|
"electron-store": "^10.1.0",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"marked": "^16.2.1",
|
"marked": "^16.2.1",
|
||||||
|
"tslib": "^2.8.1",
|
||||||
"xlsx": "^0.18.5"
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
|
|||||||
+120
-9
@@ -192,7 +192,7 @@ function createMenu() {
|
|||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'About PanConverter',
|
title: 'About PanConverter',
|
||||||
message: 'PanConverter',
|
message: 'PanConverter',
|
||||||
detail: 'A cross-platform Markdown editor and converter using Pandoc.\n\nVersion: 1.3.4\nAuthor: Amit Haridas\nEmail: amit.wh@gmail.com\nLicense: MIT\n\nFeatures:\n• Tabbed interface for multiple files\n• Advanced markdown editing with live preview\n• Enhanced PDF export with LaTeX engines\n• File association support for .md files\n• Improved preview typography and spacing\n• Adjustable font sizes via menu (Ctrl+Shift+Plus/Minus)\n• Complete theme support including Monokai fixes\n• Find & replace with match highlighting\n• Line numbers and auto-indentation\n• Export to multiple formats via Pandoc\n• PowerPoint & presentation export\n• Export tables to Excel/ODS spreadsheets\n• Document import & conversion\n• Table creation helper\n• Multiple themes support\n• Undo/redo functionality',
|
detail: 'A cross-platform Markdown editor and converter using Pandoc.\n\nVersion: 1.3.6\nAuthor: Amit Haridas\nEmail: amit.wh@gmail.com\nLicense: MIT\n\nFeatures:\n• Tabbed interface for multiple files\n• Advanced markdown editing with live preview\n• Enhanced PDF export with built-in Electron fallback\n• File association support for .md files\n• Improved preview typography and spacing\n• Adjustable font sizes via menu (Ctrl+Shift+Plus/Minus)\n• Complete theme support including Monokai fixes\n• Find & replace with match highlighting\n• Line numbers and auto-indentation\n• Export to multiple formats via Pandoc\n• PowerPoint & presentation export\n• Export tables to Excel/ODS spreadsheets\n• Document import & conversion\n• Table creation helper\n• Multiple themes support\n• Undo/redo functionality',
|
||||||
buttons: ['OK']
|
buttons: ['OK']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -268,15 +268,126 @@ function exportFile(format) {
|
|||||||
if (fallbackError) {
|
if (fallbackError) {
|
||||||
// Final fallback to wkhtmltopdf
|
// Final fallback to wkhtmltopdf
|
||||||
const htmlToPdfCmd = `pandoc "${currentFile}" -t html5 | wkhtmltopdf - "${outputFile}"`;
|
const htmlToPdfCmd = `pandoc "${currentFile}" -t html5 | wkhtmltopdf - "${outputFile}"`;
|
||||||
exec(htmlToPdfCmd, (finalError) => {
|
exec(htmlToPdfCmd, async (finalError) => {
|
||||||
if (finalError) {
|
if (finalError) {
|
||||||
dialog.showErrorBox('PDF Export Error',
|
// Ultimate fallback: Use Electron's built-in PDF export
|
||||||
`Failed to export PDF. Please ensure you have one of the following installed:\n` +
|
try {
|
||||||
`• XeLaTeX (recommended): sudo apt-get install texlive-xetex\n` +
|
const marked = require('marked');
|
||||||
`• PDFLaTeX: sudo apt-get install texlive-latex-base\n` +
|
const fs = require('fs');
|
||||||
`• wkhtmltopdf: sudo apt-get install wkhtmltopdf\n\n` +
|
|
||||||
`Error: ${finalError.message}`
|
// Read markdown file
|
||||||
);
|
const markdownContent = fs.readFileSync(currentFile, 'utf8');
|
||||||
|
|
||||||
|
// Convert markdown to HTML
|
||||||
|
const htmlContent = marked.parse(markdownContent);
|
||||||
|
|
||||||
|
// Create full HTML document with styling
|
||||||
|
const fullHtml = `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 40px;
|
||||||
|
}
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 2px 4px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-family: Consolas, Monaco, 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 1em;
|
||||||
|
border-radius: 5px;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
pre code {
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
blockquote {
|
||||||
|
border-left: 4px solid #ddd;
|
||||||
|
margin-left: 0;
|
||||||
|
padding-left: 1em;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #0066cc;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
${htmlContent}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Create a hidden window to render and export PDF
|
||||||
|
const { BrowserWindow } = require('electron');
|
||||||
|
const pdfWindow = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
contextIsolation: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await pdfWindow.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(fullHtml)}`);
|
||||||
|
|
||||||
|
const pdfData = await pdfWindow.webContents.printToPDF({
|
||||||
|
marginsType: 1, // Use default margins
|
||||||
|
pageSize: 'A4',
|
||||||
|
printBackground: true,
|
||||||
|
printSelectionOnly: false,
|
||||||
|
landscape: false
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.writeFileSync(outputFile, pdfData);
|
||||||
|
pdfWindow.close();
|
||||||
|
|
||||||
|
showExportSuccess(outputFile);
|
||||||
|
} catch (electronPdfError) {
|
||||||
|
dialog.showErrorBox('PDF Export Error',
|
||||||
|
`Failed to export PDF. The built-in PDF export encountered an error.\n\n` +
|
||||||
|
`For better PDF export, please install one of the following:\n` +
|
||||||
|
`• XeLaTeX (recommended)\n` +
|
||||||
|
`• PDFLaTeX\n` +
|
||||||
|
`• wkhtmltopdf\n\n` +
|
||||||
|
`Error: ${electronPdfError.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showExportSuccess(outputFile);
|
showExportSuccess(outputFile);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user