mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 17:29:29 +05:30
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:
@@ -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 };
|
||||
|
||||
@@ -41,4 +41,4 @@ async function patchManifest(epubPath, fonts) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
module.exports = { patchManifest };
|
||||
module.exports = { patchManifest };
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -44,4 +44,4 @@ function build({ fontTtfPath, boldTtfPath, ligatures }) {
|
||||
`;
|
||||
}
|
||||
|
||||
module.exports = { build };
|
||||
module.exports = { build };
|
||||
|
||||
Reference in New Issue
Block a user