Skip to content

Commit

Permalink
After npm run prettier
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Dujava <[email protected]>
  • Loading branch information
jdujava committed Apr 20, 2024
1 parent d058085 commit d2203d4
Show file tree
Hide file tree
Showing 29 changed files with 357 additions and 345 deletions.
40 changes: 20 additions & 20 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async function generateOptionTypes() {
async function generateVersionFile() {
await writeFile(
join(BUILD_PATH, 'version.ts'),
`export const version = "${version}";`,
`export const version = "${version}";`
);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ async function generateCLIHelp() {
await writeFile(
join(BUILD_PATH, 'manPage.ts'),
jsBanner.join('\n') +
`export const manPage = ${JSON.stringify(help, null, '\t')};`,
`export const manPage = ${JSON.stringify(help, null, '\t')};`
);
}

Expand All @@ -151,7 +151,7 @@ async function generateManPage() {
...DESCRIPTION.map((d) =>
wrapText(d, 61)
.map((line) => ` ${line}`)
.join('\n'),
.join('\n')
),
'',
'OPTIONS',
Expand All @@ -161,7 +161,7 @@ async function generateManPage() {
'',
'AUTHOR',
` ${author}`,
].join('\n'),
].join('\n')
);
}

Expand All @@ -171,39 +171,39 @@ async function generateReadme() {
join(__dirname, 'README.md'),
readme.replace(
/```manpage.*?```/s,
'```manpage\n' + formatOptions(2, 84).join('\n') + '\n```',
),
'```manpage\n' + formatOptions(2, 84).join('\n') + '\n```'
)
);
}

async function generateKeyTemplatePage() {
let doc = await readFile(
join(__dirname, 'docs/manual/key-generation.html'),
'utf8',
'utf8'
);
const markers = Object.entries(SPECIAL_MARKERS).map(
([k, { description }]) => `<li><code>[${k}]</code>: ${description}</li>`,
([k, { description }]) => `<li><code>[${k}]</code>: ${description}</li>`
);
const modifiers = Object.entries(MODIFIERS).map(
([k, { description }]) => `<li><code>:${k}</code>: ${description}</li>`,
([k, { description }]) => `<li><code>:${k}</code>: ${description}</li>`
);

doc = doc
.replace(
/<!--DEFAULT_KEY-->.*?<!--END-->/s,
`<!--DEFAULT_KEY-->${DEFAULT_KEY_TEMPLATE}<!--END-->`,
`<!--DEFAULT_KEY-->${DEFAULT_KEY_TEMPLATE}<!--END-->`
)
.replace(
/<!--MARKERS-->.*?<!--END-->/s,
`<!--MARKERS-->${markers.join('\n')}<!--END-->`,
`<!--MARKERS-->${markers.join('\n')}<!--END-->`
)
.replace(
/<!--MODIFIERS-->.*?<!--END-->/s,
`<!--MODIFIERS-->${modifiers.join('\n')}<!--END-->`,
`<!--MODIFIERS-->${modifiers.join('\n')}<!--END-->`
)
.replace(
/<!--WORDS-->.*?<!--END-->/s,
`<!--WORDS-->${[...functionWords].join(', ')}<!--END-->`,
`<!--WORDS-->${[...functionWords].join(', ')}<!--END-->`
);
await writeFile(join(__dirname, 'docs/manual/key-generation.html'), doc);
}
Expand All @@ -222,14 +222,14 @@ function formatOptions(indent: number, lineWidth: number): string[] {
description.push(
'Examples:',
opt.examples.filter((example) => example).join(', '),
'',
''
);
}

return [
Object.keys(opt.cli).join(', '),
...description.flatMap((line) =>
wrapText(line, lineWidth - indent - 4).map((line) => ` ${line}`),
wrapText(line, lineWidth - indent - 4).map((line) => ` ${line}`)
),
].map((line) => `${' '.repeat(indent)}${line}`);
});
Expand Down Expand Up @@ -258,7 +258,7 @@ async function buildJSBundle() {
});
await writeFile(
'bibtex-tidy.js',
text + `\nmodule.exports = exports.default;`,
text + `\nmodule.exports = exports.default;`
);
console.timeEnd('JS bundle built');
}
Expand Down Expand Up @@ -361,7 +361,7 @@ const regexpuPlugin: Plugin = {
unicodePropertyEscapes: 'transform',
});
return `(/${newPattern}/${flags.replace('u', '')}`;
},
}
);
return { contents: newContents, loader: 'ts' };
});
Expand All @@ -376,7 +376,7 @@ const regexpuPlugin: Plugin = {
*/
async function transpileForOldBrowsers(
bundle: OutputFile,
options?: Options,
options?: Options
): Promise<Output> {
return await swc(bundle.text, {
filename: bundle.path,
Expand All @@ -397,7 +397,7 @@ if (process.argv.includes('--serve')) {
generateKeyTemplatePage(),
generateCLIHelp(),
generateReadme(),
]),
])
)
.then(() =>
Promise.all([
Expand All @@ -407,6 +407,6 @@ if (process.argv.includes('--serve')) {
buildJSBundle(),
buildCLI(),
buildWebBundle(),
]),
])
);
}
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
58 changes: 41 additions & 17 deletions docs/manual/key-generation.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<title>BibTex Tidy: Key Generation</title>
Expand Down Expand Up @@ -66,23 +66,43 @@ <h2>Field markers</h2>
<h2>Special markers</h2>

<ul>
<!--MARKERS--><li><code>[auth]</code>: Last name of first authors</li>
<li><code>[authEtAl]</code>: If 1 or 2 authors, both authors, otherwise first author and EtAl</li>
<li><code>[authors]</code>: Last name all authors</li>
<li><code>[authorsN]</code>: Last name N authors, with EtAl if more</li>
<li><code>[veryshorttitle]</code>: First non-function word of the title</li>
<li><code>[shorttitle]</code>: First three non-function words of the title</li>
<li><code>[title]</code>: Full title, capitalized</li>
<li><code>[fulltitle]</code>: Full title, verbatim</li>
<li><code>[year]</code>: Year</li>
<li><code>[duplicateLetter]</code>: If the multiple entries end up with the same key, then insert a letter a-z. By default this will be inserted at the end.</li>
<li><code>[duplicateNumber]</code>: If the multiple entries end up with the same key, then insert a number.</li><!--END-->
<!--MARKERS-->
<li><code>[auth]</code>: Last name of first authors</li>
<li>
<code>[authEtAl]</code>: If 1 or 2 authors, both authors, otherwise
first author and EtAl
</li>
<li><code>[authors]</code>: Last name all authors</li>
<li><code>[authorsN]</code>: Last name N authors, with EtAl if more</li>
<li>
<code>[veryshorttitle]</code>: First non-function word of the title
</li>
<li>
<code>[shorttitle]</code>: First three non-function words of the title
</li>
<li><code>[title]</code>: Full title, capitalized</li>
<li><code>[fulltitle]</code>: Full title, verbatim</li>
<li><code>[year]</code>: Year</li>
<li>
<code>[duplicateLetter]</code>: If the multiple entries end up with the
same key, then insert a letter a-z. By default this will be inserted at
the end.
</li>
<li>
<code>[duplicateNumber]</code>: If the multiple entries end up with the
same key, then insert a number.
</li>
<!--END-->
</ul>

<p>
Function words:
<span
><!--WORDS-->a, about, above, across, against, along, among, an, and, around, at, before, behind, below, beneath, beside, between, beyond, but, by, down, during, except, for, from, in, inside, into, like, near, nor, of, off, on, onto, or, since, so, the, through, to, toward, under, until, up, upon, with, within, without, yet<!--END--></span
><!--WORDS-->a, about, above, across, against, along, among, an, and,
around, at, before, behind, below, beneath, beside, between, beyond,
but, by, down, during, except, for, from, in, inside, into, like, near,
nor, of, off, on, onto, or, since, so, the, through, to, toward, under,
until, up, upon, with, within, without, yet<!--END--></span
>
</p>

Expand All @@ -95,10 +115,14 @@ <h2>Modifiers</h2>
</p>

<ul>
<!--MODIFIERS--><li><code>:required</code>: If data is missing, revert to existing key</li>
<li><code>:lower</code>: Convert to lowercase</li>
<li><code>:upper</code>: Convert to uppercase</li>
<li><code>:capitalize</code>: Capitalize first letter of each word</li><!--END-->
<!--MODIFIERS-->
<li>
<code>:required</code>: If data is missing, revert to existing key
</li>
<li><code>:lower</code>: Convert to lowercase</li>
<li><code>:upper</code>: Convert to uppercase</li>
<li><code>:capitalize</code>: Capitalize first letter of each word</li>
<!--END-->
</ul>
</body>
</html>
Loading

0 comments on commit d2203d4

Please sign in to comment.