diff --git a/README.md b/README.md index 72b73ea..d891ae2 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,11 @@ bibtex-tidy references.bib Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}. + Fields can be excluded. + + Examples: + --sort-fields=publisher,volume + --escape, --no-escape Escape special characters, such as umlaut. This ensures correct typesetting with latex. Enabled by default. diff --git a/bibtex-tidy.0 b/bibtex-tidy.0 index ec6eb61..57510cf 100644 --- a/bibtex-tidy.0 +++ b/bibtex-tidy.0 @@ -86,6 +86,11 @@ OPTIONS Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}. + Fields can be excluded. + + Examples: + --sort-fields=publisher,volume + --escape, --no-escape Escape special characters, such as umlaut. This ensures correct typesetting with latex. Enabled by default. diff --git a/bibtex-tidy.d.ts b/bibtex-tidy.d.ts index 3c5298f..22e551a 100644 --- a/bibtex-tidy.d.ts +++ b/bibtex-tidy.d.ts @@ -80,8 +80,9 @@ export declare type BibTeXTidyOptions = { * Drop all caps * * Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}. + * Fields can be excluded. */ - dropAllCaps?: boolean; + dropAllCaps?: boolean | string[]; /** * Escape special characters * diff --git a/bibtex-tidy.js b/bibtex-tidy.js index 8d04ac6..2748831 100644 --- a/bibtex-tidy.js +++ b/bibtex-tidy.js @@ -191,10 +191,15 @@ var optionDefinitions = [{ cli: { "--drop-all-caps": true }, - toCLI: val => val ? "--drop-all-caps" : void 0, + toCLI: val => { + if (Array.isArray(val) && val.length > 0) return `--drop-all-caps=${val.join(",")}`; + if (val === true) return "--drop-all-caps"; + return void 0; + }, title: "Drop all caps", - description: ["Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}."], - type: "boolean", + description: ["Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}.", "Fields can be excluded."], + examples: ["--sort-fields=publisher,volume"], + type: "boolean | string[]", defaultValue: false }, { key: "escape", @@ -1090,7 +1095,7 @@ function formatValue(field, options) { } if (dropAllCaps && !value.match(/[a-z]/)) { - value = titleCase(value); + value = Array.isArray(dropAllCaps) && dropAllCaps.includes(nameLowerCase) ? value : titleCase(value); } if (nameLowerCase === "url" && encodeUrls) { diff --git a/bin/bibtex-tidy b/bin/bibtex-tidy index 62da2e1..3e3f49c 100755 --- a/bin/bibtex-tidy +++ b/bin/bibtex-tidy @@ -218,12 +218,20 @@ var optionDefinitions = [ { key: "dropAllCaps", cli: { "--drop-all-caps": true }, - toCLI: (val) => val ? "--drop-all-caps" : void 0, + toCLI: (val) => { + if (Array.isArray(val) && val.length > 0) + return `--drop-all-caps=${val.join(",")}`; + if (val === true) + return "--drop-all-caps"; + return void 0; + }, title: "Drop all caps", description: [ - "Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}." + "Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}.", + "Fields can be excluded." ], - type: "boolean", + examples: ["--sort-fields=publisher,volume"], + type: "boolean | string[]", defaultValue: false }, { @@ -3385,7 +3393,7 @@ function formatValue(field, options) { value = removeEnclosingBraces(value); } if (dropAllCaps && !value.match(/[a-z]/)) { - value = titleCase(value); + value = Array.isArray(dropAllCaps) && dropAllCaps.includes(nameLowerCase) ? value : titleCase(value); } if (nameLowerCase === "url" && encodeUrls) { value = escapeURL(value); @@ -3772,6 +3780,11 @@ var manPage = [ " Where values are all caps, make them title case. For example, {JOURNAL OF", " TEA} will become {Journal of Tea}.", " ", + " Fields can be excluded.", + " ", + " Examples:", + " --sort-fields=publisher,volume", + " ", " --escape, --no-escape", " Escape special characters, such as umlaut. This ensures correct typesetting", " with latex. Enabled by default.", diff --git a/docs/bundle.js b/docs/bundle.js index e41f1d8..ba66594 100644 --- a/docs/bundle.js +++ b/docs/bundle.js @@ -14155,10 +14155,15 @@ cli: { "--drop-all-caps": true }, - toCLI: val => val ? "--drop-all-caps" : void 0, + toCLI: val => { + if (Array.isArray(val) && val.length > 0) return `--drop-all-caps=${val.join(",")}`; + if (val === true) return "--drop-all-caps"; + return void 0; + }, title: "Drop all caps", - description: ["Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}."], - type: "boolean", + description: ["Where values are all caps, make them title case. For example, {JOURNAL OF TEA} will become {Journal of Tea}.", "Fields can be excluded."], + examples: ["--sort-fields=publisher,volume"], + type: "boolean | string[]", defaultValue: false }, { key: "escape", @@ -15054,7 +15059,7 @@ ${indent}${name.trim().padEnd(align - 1)} = ${value}`; } if (dropAllCaps && !value.match(/[a-z]/)) { - value = titleCase(value); + value = Array.isArray(dropAllCaps) && dropAllCaps.includes(nameLowerCase) ? value : titleCase(value); } if (nameLowerCase === "url" && encodeUrls) { @@ -15543,7 +15548,7 @@ ${valIndent}`) + "\n" + indent; merge: options.merge.checked ? options.mergeStrategy.value : false, enclosingBraces: options.enclosingBraces.checked && options.enclosingBracesList.value.length > 0 && options.enclosingBracesList.value.split(/[\n\t ,]+/), stripEnclosingBraces: options.stripEnclosingBraces.checked, - dropAllCaps: options.dropAllCaps.checked, + dropAllCaps: options.dropAllCaps.checked && (options.excludeDropAllCapsList.value.split(/[\n\t ,]+/).filter(Boolean).length === 0 ? true : options.excludeDropAllCapsList.value.split(/[\n\t ,]+/)), sortFields: options.sortFields.checked && options.sortFieldList.value.length > 0 && options.sortFieldList.value.split(/[\n\t ,]+/), stripComments: options.stripComments.checked, tidyComments: options.tidyComments.checked, diff --git a/docs/index.html b/docs/index.html index 7799a64..e919124 100644 --- a/docs/index.html +++ b/docs/index.html @@ -118,6 +118,12 @@