mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a780f2984a | ||
|
|
0c9961d412 | ||
|
|
ed7a80f99e | ||
|
|
18b7d82610 | ||
|
|
cd1f7ac37d |
@@ -0,0 +1,10 @@
|
|||||||
|
name: New MCP server
|
||||||
|
version: 0.0.1
|
||||||
|
schema: v1
|
||||||
|
mcpServers:
|
||||||
|
- name: New MCP server
|
||||||
|
command: npx
|
||||||
|
args:
|
||||||
|
- -y
|
||||||
|
- <your-mcp-server>
|
||||||
|
env: {}
|
||||||
+3
-9
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pan-converter",
|
"name": "pan-converter",
|
||||||
"version": "1.5.0",
|
"version": "1.5.4",
|
||||||
"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": {
|
||||||
@@ -68,8 +68,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"mac": {
|
"mac": {
|
||||||
"category": "public.app-category.productivity",
|
"category": "public.app-category.productivity"
|
||||||
"icon": "assets/icon.icns"
|
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
"target": [
|
"target": [
|
||||||
@@ -86,7 +85,6 @@
|
|||||||
"arch": ["x64"]
|
"arch": ["x64"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "assets/icon.png",
|
|
||||||
"artifactName": "${productName}-${version}-${arch}.${ext}",
|
"artifactName": "${productName}-${version}-${arch}.${ext}",
|
||||||
"requestedExecutionLevel": "asInvoker",
|
"requestedExecutionLevel": "asInvoker",
|
||||||
"signAndEditExecutable": true
|
"signAndEditExecutable": true
|
||||||
@@ -96,9 +94,6 @@
|
|||||||
"perMachine": false,
|
"perMachine": false,
|
||||||
"allowToChangeInstallationDirectory": true,
|
"allowToChangeInstallationDirectory": true,
|
||||||
"displayLanguageSelector": true,
|
"displayLanguageSelector": true,
|
||||||
"installerIcon": "assets/icon-proper.ico",
|
|
||||||
"uninstallerIcon": "assets/icon-proper.ico",
|
|
||||||
"installerHeaderIcon": "assets/icon-proper.ico",
|
|
||||||
"createDesktopShortcut": true,
|
"createDesktopShortcut": true,
|
||||||
"createStartMenuShortcut": true,
|
"createStartMenuShortcut": true,
|
||||||
"shortcutName": "PanConverter",
|
"shortcutName": "PanConverter",
|
||||||
@@ -116,8 +111,7 @@
|
|||||||
"AppImage",
|
"AppImage",
|
||||||
"snap"
|
"snap"
|
||||||
],
|
],
|
||||||
"category": "Utility",
|
"category": "Utility"
|
||||||
"icon": "assets/icon.png"
|
|
||||||
},
|
},
|
||||||
"deb": {
|
"deb": {
|
||||||
"depends": [
|
"depends": [
|
||||||
|
|||||||
+63
-9
@@ -2,17 +2,37 @@ const { app, BrowserWindow, Menu, dialog, ipcMain, shell } = require('electron')
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
const XLSX = require('xlsx');
|
||||||
|
|
||||||
// Get the system Pandoc path
|
// Get the system Pandoc path
|
||||||
function getPandocPath() {
|
function getPandocPath() {
|
||||||
// Always use system pandoc - no bundled binaries
|
// Check common Pandoc installation locations on Windows
|
||||||
|
const commonPaths = [
|
||||||
|
'pandoc', // System PATH
|
||||||
|
path.join(process.env.USERPROFILE || '', 'AppData', 'Local', 'Pandoc', 'pandoc.exe'),
|
||||||
|
path.join('C:', 'Program Files', 'Pandoc', 'pandoc.exe'),
|
||||||
|
path.join('C:', 'Program Files (x86)', 'Pandoc', 'pandoc.exe'),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Try each path and return the first one that exists
|
||||||
|
for (const pandocPath of commonPaths) {
|
||||||
|
if (pandocPath === 'pandoc') {
|
||||||
|
// For system PATH, we'll check in checkPandocAvailable()
|
||||||
|
return pandocPath;
|
||||||
|
} else if (fs.existsSync(pandocPath)) {
|
||||||
|
return `"${pandocPath}"`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to system pandoc
|
||||||
return 'pandoc';
|
return 'pandoc';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if Pandoc is available
|
// Check if Pandoc is available
|
||||||
function checkPandocAvailable() {
|
function checkPandocAvailable() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
exec('pandoc --version', (error) => {
|
const pandocPath = getPandocPath();
|
||||||
|
exec(`${pandocPath} --version`, (error) => {
|
||||||
resolve(!error);
|
resolve(!error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -179,7 +199,8 @@ function createMenu() {
|
|||||||
{ label: 'PowerPoint (PPTX)', click: () => exportFile('pptx') },
|
{ label: 'PowerPoint (PPTX)', click: () => exportFile('pptx') },
|
||||||
{ label: 'OpenDocument Presentation (ODP)', click: () => exportFile('odp') },
|
{ label: 'OpenDocument Presentation (ODP)', click: () => exportFile('odp') },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: 'CSV (Tables)', click: () => exportSpreadsheet('csv') }
|
{ label: 'CSV (Tables)', click: () => exportSpreadsheet('csv') },
|
||||||
|
{ label: 'XLSX (Tables)', click: () => exportSpreadsheet('xlsx') }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
@@ -496,16 +517,35 @@ function showExportSuccess(outputFile) {
|
|||||||
|
|
||||||
// Helper function to export with pandoc (general)
|
// Helper function to export with pandoc (general)
|
||||||
function exportWithPandoc(pandocCmd, outputFile, format) {
|
function exportWithPandoc(pandocCmd, outputFile, format) {
|
||||||
|
console.log(`Executing Pandoc command: ${pandocCmd}`);
|
||||||
|
|
||||||
exec(pandocCmd, (error, stdout, stderr) => {
|
exec(pandocCmd, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Pandoc error for ${format}:`, error);
|
console.error(`Pandoc error for ${format}:`, error);
|
||||||
dialog.showErrorBox('Export Error',
|
console.error(`Pandoc stderr:`, stderr);
|
||||||
`Failed to export to ${format.toUpperCase()}:\n${error.message}\n\n` +
|
console.error(`Pandoc stdout:`, stdout);
|
||||||
`Command used: ${pandocCmd}\n\n` +
|
|
||||||
`Please ensure Pandoc is properly installed and accessible.`
|
// Provide more specific error messages
|
||||||
);
|
let errorMessage = `Failed to export to ${format.toUpperCase()}`;
|
||||||
|
|
||||||
|
if (error.message.includes('not found') || error.message.includes('not recognized')) {
|
||||||
|
errorMessage += '\n\nPandoc is not installed or not found in PATH.';
|
||||||
|
errorMessage += '\nPlease install Pandoc from: https://pandoc.org/installing.html';
|
||||||
|
} else if (stderr) {
|
||||||
|
errorMessage += `\n\nError details: ${stderr}`;
|
||||||
|
} else {
|
||||||
|
errorMessage += `\n\nError details: ${error.message}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorMessage += `\n\nCommand used: ${pandocCmd}`;
|
||||||
|
|
||||||
|
dialog.showErrorBox('Export Error', errorMessage);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Successfully exported to ${format}:`, outputFile);
|
console.log(`Successfully exported to ${format}:`, outputFile);
|
||||||
|
console.log(`Pandoc stdout:`, stdout);
|
||||||
|
if (stderr) {
|
||||||
|
console.warn(`Pandoc stderr (non-fatal):`, stderr);
|
||||||
|
}
|
||||||
showExportSuccess(outputFile);
|
showExportSuccess(outputFile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -858,6 +898,7 @@ ipcMain.on('export-spreadsheet', (event, { content, format }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (format === 'csv') {
|
||||||
// Convert tables to CSV format
|
// Convert tables to CSV format
|
||||||
let csvContent = '';
|
let csvContent = '';
|
||||||
tables.forEach((table, index) => {
|
tables.forEach((table, index) => {
|
||||||
@@ -877,11 +918,24 @@ ipcMain.on('export-spreadsheet', (event, { content, format }) => {
|
|||||||
|
|
||||||
// Write CSV file
|
// Write CSV file
|
||||||
fs.writeFileSync(outputFile, csvContent, 'utf-8');
|
fs.writeFileSync(outputFile, csvContent, 'utf-8');
|
||||||
|
} else if (format === 'xlsx') {
|
||||||
|
// Convert tables to XLSX format
|
||||||
|
const workbook = XLSX.utils.book_new();
|
||||||
|
|
||||||
|
tables.forEach((table, index) => {
|
||||||
|
const sheetName = tables.length > 1 ? `Table${index + 1}` : 'Table';
|
||||||
|
const worksheet = XLSX.utils.aoa_to_sheet(table);
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Write XLSX file
|
||||||
|
XLSX.writeFile(workbook, outputFile);
|
||||||
|
}
|
||||||
|
|
||||||
dialog.showMessageBox(mainWindow, {
|
dialog.showMessageBox(mainWindow, {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Export Complete',
|
title: 'Export Complete',
|
||||||
message: `CSV exported successfully to ${outputFile}`,
|
message: `${format.toUpperCase()} exported successfully to ${outputFile}`,
|
||||||
buttons: ['OK']
|
buttons: ['OK']
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -854,6 +854,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const advancedOptions = document.getElementById('advanced-export-options');
|
const advancedOptions = document.getElementById('advanced-export-options');
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
advancedOptions.classList.remove('hidden');
|
advancedOptions.classList.remove('hidden');
|
||||||
|
// Scroll the advanced options into view after they become visible
|
||||||
|
setTimeout(() => {
|
||||||
|
advancedOptions.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||||
|
}, 100);
|
||||||
} else {
|
} else {
|
||||||
advancedOptions.classList.add('hidden');
|
advancedOptions.classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -859,8 +859,9 @@ body.theme-github .status-bar {
|
|||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
||||||
width: 90%;
|
width: 90%;
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
max-height: 80vh;
|
max-height: 90vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.export-dialog-header {
|
.export-dialog-header {
|
||||||
@@ -1437,7 +1438,9 @@ body.theme-github .line-numbers {
|
|||||||
|
|
||||||
.advanced-options {
|
.advanced-options {
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
overflow: hidden;
|
overflow: visible;
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.advanced-options.hidden {
|
.advanced-options.hidden {
|
||||||
|
|||||||
Reference in New Issue
Block a user