style: apply Prettier formatting

Run after full implementation to enforce 2-space / 100-char / single-quote
conventions across all new + adjacent files.
This commit is contained in:
2026-08-23 19:31:33 +05:30
parent 58868eece0
commit 7095b34280
14 changed files with 134 additions and 45 deletions
+4 -1
View File
@@ -142,7 +142,10 @@
line-height: 1.3;
color: #00ff00;
white-space: pre;
font-feature-settings: 'liga' 0, 'calt' 0, 'dlig' 0;
font-feature-settings:
'liga' 0,
'calt' 0,
'dlig' 0;
}
.template-grid {
+36 -13
View File
@@ -575,7 +575,9 @@ function checkPandocAvailability() {
pandocAvailable = !error;
if (!error) {
const m = String(stdout).match(/pandoc\s+(\d+)\.(\d+)/);
pandocVersionCache = m ? { major: Number(m[1]), minor: Number(m[2]) } : { major: 0, minor: 0 };
pandocVersionCache = m
? { major: Number(m[1]), minor: Number(m[2]) }
: { major: 0, minor: 0 };
} else {
pandocVersionCache = { major: 0, minor: 0 };
}
@@ -2786,7 +2788,8 @@ function performExportWithOptions(format, options) {
if (bold) fonts.push({ path: bold, family, weight: 700 });
if (fonts.length) await DocxFontEmbedder.embed(outputFile, fonts);
} catch (embedErr) {
if (typeof console !== 'undefined') console.warn('[docx] font embed failed:', embedErr.message);
if (typeof console !== 'undefined')
console.warn('[docx] font embed failed:', embedErr.message);
}
if (tempInputFile) {
try {
@@ -2903,17 +2906,24 @@ function performExportWithOptions(format, options) {
const familyKey = readSettingsJsonCached().monospaceFont || 'jetbrains-mono';
const regular = MonospaceFontConfig.getMonoFontTtfPath(familyKey, 400);
const fonts = [];
if (regular) fonts.push({ path: regular, family: familyKey === 'fira-code' ? 'Fira Code' : 'JetBrains Mono', weight: 400 });
if (regular)
fonts.push({
path: regular,
family: familyKey === 'fira-code' ? 'Fira Code' : 'JetBrains Mono',
weight: 400,
});
if (fonts.length) {
const patched = await EpubFontEmbedder.patchManifest(outputFile, fonts);
try {
fs.renameSync(patched, outputFile);
} catch (renameErr) {
if (typeof console !== 'undefined') console.warn('[epub] could not overwrite with patched EPUB:', renameErr.message);
if (typeof console !== 'undefined')
console.warn('[epub] could not overwrite with patched EPUB:', renameErr.message);
}
}
} catch (patchErr) {
if (typeof console !== 'undefined') console.warn('[epub] manifest patch failed:', patchErr.message);
if (typeof console !== 'undefined')
console.warn('[epub] manifest patch failed:', patchErr.message);
}
showExportSuccess(outputFile);
});
@@ -3619,13 +3629,16 @@ ipcMain.on('export-with-options', (event, { format, options }) => {
});
// Handle batch conversion
ipcMain.on('batch-convert', (event, { inputFolder, outputFolder, format, options, includeSubfolders }) => {
if (!conversionLimiter()) {
mainWindow.webContents.send('conversion-status', 'Please wait before converting again...');
return;
ipcMain.on(
'batch-convert',
(event, { inputFolder, outputFolder, format, options, includeSubfolders }) => {
if (!conversionLimiter()) {
mainWindow.webContents.send('conversion-status', 'Please wait before converting again...');
return;
}
performBatchConversion(inputFolder, outputFolder, format, options, includeSubfolders);
}
performBatchConversion(inputFolder, outputFolder, format, options, includeSubfolders);
});
);
// Handle folder selection for batch conversion
ipcMain.on('select-folder', (event, type) => {
@@ -3734,7 +3747,13 @@ function extractTablesFromMarkdown(markdown) {
}
return tables;
}
async function performBatchConversion(inputFolder, outputFolder, format, options, includeSubfolders = true) {
async function performBatchConversion(
inputFolder,
outputFolder,
format,
options,
includeSubfolders = true
) {
if (!fs.existsSync(inputFolder)) {
dialog.showErrorBox('Error', 'Input folder does not exist');
return;
@@ -4093,7 +4112,11 @@ async function performBatchConversion(inputFolder, outputFolder, format, options
}
if (error) {
console.error(`Batch: Failed to convert ${path.basename(inputFile)}:`, error.message, stderr);
console.error(
`Batch: Failed to convert ${path.basename(inputFile)}:`,
error.message,
stderr
);
} else {
// Add headers/footers to DOCX if enabled
if (format === 'docx' && headerFooterSettings.enabled) {
+12 -5
View File
@@ -38,8 +38,9 @@ async function patchZipWithFonts(inputPath, fonts) {
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n` +
`<w:fonts xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/main">\n` +
fonts
.map((f, i) =>
` <w:font w:name="${f.family}"><w:embedRegular r:id="${generatedRId(i)}" xmlns:r="${REL_NS}"/></w:font>`
.map(
(f, i) =>
` <w:font w:name="${f.family}"><w:embedRegular r:id="${generatedRId(i)}" xmlns:r="${REL_NS}"/></w:font>`
)
.join('\n') +
`\n</w:fonts>\n`;
@@ -59,11 +60,17 @@ async function patchZipWithFonts(inputPath, fonts) {
const ttfCt = 'application/x-font-ttf';
const filePart = `/word/fonts/${path.basename(f.path)}`;
if (!ct.includes(`PartName="${filePart}"`)) {
ct = ct.replace('</Types>', `<Override PartName="${filePart}" ContentType="${ttfCt}"/></Types>`);
ct = ct.replace(
'</Types>',
`<Override PartName="${filePart}" ContentType="${ttfCt}"/></Types>`
);
}
}
if (!ct.includes('Default Extension="ttf"')) {
ct = ct.replace('</Types>', '<Default Extension="ttf" ContentType="application/x-font-ttf"/></Types>');
ct = ct.replace(
'</Types>',
'<Default Extension="ttf" ContentType="application/x-font-ttf"/></Types>'
);
}
zip.file(ctPath, ct);
@@ -116,4 +123,4 @@ async function embed(docxPath, fonts) {
return patchZipWithFonts(docxPath, fonts);
}
module.exports = { embed };
module.exports = { embed };
+1 -1
View File
@@ -41,4 +41,4 @@ async function patchManifest(epubPath, fonts) {
return tmp;
}
module.exports = { patchManifest };
module.exports = { patchManifest };
+18 -5
View File
@@ -2,12 +2,19 @@
const fs = require('fs');
const path = require('path');
const { getActiveMonoFont, isLigaturesEnabled, FAMILY_BY_KEY } = require('./settings/monospaceSettings');
const {
getActiveMonoFont,
isLigaturesEnabled,
FAMILY_BY_KEY,
} = require('./settings/monospaceSettings');
const WEIGHT_BY_KEY = { 300: 'Light', 400: 'Regular', 500: 'Medium', 600: 'SemiBold', 700: 'Bold' };
function getAppRoot() {
if (process.resourcesPath && fs.existsSync(path.join(process.resourcesPath, 'app.asar.unpacked'))) {
if (
process.resourcesPath &&
fs.existsSync(path.join(process.resourcesPath, 'app.asar.unpacked'))
) {
return process.resourcesPath;
}
return path.resolve(__dirname, '..', '..');
@@ -32,12 +39,18 @@ function getMonoFontTtfPath(familyKey, weight = 400) {
if (fs.existsSync(p)) return p;
}
const filename = path.basename(candidates[candidates.length - 1]);
console.warn(`[MonospaceFontConfig] bundled font missing: ${filename}; falling back to system monospace`);
console.warn(
`[MonospaceFontConfig] bundled font missing: ${filename}; falling back to system monospace`
);
return null;
}
function ligaturesEnabled(settings) { return isLigaturesEnabled(settings); }
function ligaturesEnabled(settings) {
return isLigaturesEnabled(settings);
}
function getActiveFamily(settings) { return getActiveMonoFont(settings); }
function getActiveFamily(settings) {
return getActiveMonoFont(settings);
}
module.exports = { getMonoFontTtfPath, ligaturesEnabled, getActiveFamily };
+1 -1
View File
@@ -44,4 +44,4 @@ function build({ fontTtfPath, boldTtfPath, ligatures }) {
`;
}
module.exports = { build };
module.exports = { build };
+4 -2
View File
@@ -27,7 +27,8 @@ function buildFontFaceBlock(familyKey) {
return `@font-face { font-family: '${family}'; font-weight: 400; font-style: normal; src: url('${dataUri}') format('woff2'); }`;
} catch (err) {
// Non-fatal: fall back to the system monospace stack declared in styles-modern.css.
if (typeof console !== 'undefined') console.warn('[print-preview] font embed failed:', err.message);
if (typeof console !== 'undefined')
console.warn('[print-preview] font embed failed:', err.message);
return '';
}
}
@@ -125,7 +126,8 @@ class PrintPreview {
const width = orientation === 'landscape' ? size.height : size.width;
const height = orientation === 'landscape' ? size.width : size.height;
const family = this._monospaceSettings.monospaceFont === 'fira-code' ? 'Fira Code' : 'JetBrains Mono';
const family =
this._monospaceSettings.monospaceFont === 'fira-code' ? 'Fira Code' : 'JetBrains Mono';
const ligaturesOn = this._monospaceSettings.monospaceLigatures === true;
const featureSettings = ligaturesOn ? 'normal' : "'liga' 0, 'calt' 0, 'dlig' 0";
const fontFaceBlock = buildFontFaceBlock(this._monospaceSettings.monospaceFont);
Binary file not shown.