From 514bb13a89cca2e7713e0d89d535fac68c14e538 Mon Sep 17 00:00:00 2001 From: Emiliano Heyns Date: Mon, 15 Apr 2024 08:48:43 +0200 Subject: [PATCH] cleanup --- re.ts | 12 +++ sentence-case.ts | 8 +- test/other/mid-word-capital.bib | 11 +++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ .../other/mid-word-capital.bib.snap | 97 +++++++++++++++++++ tokenizer.ts | 33 ++----- 22 files changed, 1785 insertions(+), 25 deletions(-) create mode 100644 re.ts create mode 100644 test/other/mid-word-capital.bib create mode 100644 test/tap-snapshots/sentencecase=off^caseprotection=as-needed/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=off^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=off^caseprotection=off/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=off^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=off^caseprotection=strict/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=off^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on+guess^caseprotection=off/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on+guess^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on+guess^caseprotection=strict/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on+guess^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on^caseprotection=as-needed/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on^caseprotection=off/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on^caseprotection=strict/other/mid-word-capital.bib.snap create mode 100644 test/tap-snapshots/sentencecase=on^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap diff --git a/re.ts b/re.ts new file mode 100644 index 000000000..33535813f --- /dev/null +++ b/re.ts @@ -0,0 +1,12 @@ +export type CharCategory = { + name: string + alias: string + isBmpLast: boolean + bmp: string +} + +export function match(cats: CharCategory[], extra?: string, neg=false): string { + return `[${neg ? '^' : ''}${cats.map(cat => cat.bmp).join('')}${extra || ''}]` +} + +export const categories: CharCategory[] = require('xregexp/tools/output/categories') diff --git a/sentence-case.ts b/sentence-case.ts index 8bbf6d700..bb0579da7 100644 --- a/sentence-case.ts +++ b/sentence-case.ts @@ -1,8 +1,14 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import { tokenize, Token, connectedInnerWord } from './tokenizer' +import { tokenize, Token } from './tokenizer' import { merge } from './merge' +import * as rx from './re' + +const Lu: string = rx.match(rx.categories.filter(cat => cat.name === 'Lu')) +const Ll: string = rx.match(rx.categories.filter(cat => cat.name === 'Ll')) +const connectedInnerWord = new RegExp(`-${Lu}${Ll}*(?=-|$)`, 'g') + // eslint-disable-next-line no-magic-numbers // const show = (obj: any): string => JSON.stringify(obj, null, 2).replace(/[\u007F-\uFFFF]/g, chr => `\\u${(`0000${chr.charCodeAt(0).toString(16)}`).substr(-4)}`) diff --git a/test/other/mid-word-capital.bib b/test/other/mid-word-capital.bib new file mode 100644 index 000000000..0bcba03ff --- /dev/null +++ b/test/other/mid-word-capital.bib @@ -0,0 +1,11 @@ +@article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} +} diff --git a/test/tap-snapshots/sentencecase=off^caseprotection=as-needed/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=off^caseprotection=as-needed/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..247df54d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=off^caseprotection=as-needed/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth Evolution and Microstructural Characterization of Semipolar (112̄2) GaN Selectively Grown on Etched r-Plane Sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=off^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=off^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..247df54d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=off^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth Evolution and Microstructural Characterization of Semipolar (112̄2) GaN Selectively Grown on Etched r-Plane Sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=off^caseprotection=off/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=off^caseprotection=off/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..247df54d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=off^caseprotection=off/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth Evolution and Microstructural Characterization of Semipolar (112̄2) GaN Selectively Grown on Etched r-Plane Sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=off^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=off^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..247df54d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=off^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth Evolution and Microstructural Characterization of Semipolar (112̄2) GaN Selectively Grown on Etched r-Plane Sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=off^caseprotection=strict/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=off^caseprotection=strict/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..247df54d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=off^caseprotection=strict/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth Evolution and Microstructural Characterization of Semipolar (112̄2) GaN Selectively Grown on Etched r-Plane Sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=off^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=off^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..247df54d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=off^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth Evolution and Microstructural Characterization of Semipolar (112̄2) GaN Selectively Grown on Etched r-Plane Sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on+guess^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on+guess^caseprotection=off/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on+guess^caseprotection=off/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on+guess^caseprotection=off/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on+guess^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on+guess^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on+guess^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on+guess^caseprotection=strict/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on+guess^caseprotection=strict/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..062a9c3d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on+guess^caseprotection=strict/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on+guess^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on+guess^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..062a9c3d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on+guess^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on^caseprotection=as-needed/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on^caseprotection=as-needed/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on^caseprotection=as-needed/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on^caseprotection=as-needed^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on^caseprotection=off/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on^caseprotection=off/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on^caseprotection=off/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..b4ff3e655 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on^caseprotection=off^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on^caseprotection=strict/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on^caseprotection=strict/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..062a9c3d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on^caseprotection=strict/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/test/tap-snapshots/sentencecase=on^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap b/test/tap-snapshots/sentencecase=on^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap new file mode 100644 index 000000000..062a9c3d2 --- /dev/null +++ b/test/tap-snapshots/sentencecase=on^caseprotection=strict^preservequoted/other/mid-word-capital.bib.snap @@ -0,0 +1,97 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/all.js > TAP > other=mid-word-capital.bib > must match snapshot 1`] = ` +Object { + "comments": Array [], + "entries": Array [ + Object { + "fields": Object { + "author": Array [ + Object { + "firstName": "Benjamin", + "lastName": "Leung", + }, + Object { + "firstName": "Qian", + "lastName": "Sun", + }, + Object { + "firstName": "Christopher", + "lastName": "Yerino", + }, + Object { + "firstName": "Yu", + "lastName": "Zhang", + }, + Object { + "firstName": "Jung", + "lastName": "Han", + }, + Object { + "firstName": "Bo", + "lastName": "Hyun Kong", + }, + Object { + "firstName": "Hyung", + "lastName": "Koun Cho", + }, + Object { + "firstName": "Kuan-Yung", + "lastName": "Liao", + }, + Object { + "firstName": "Yun-Li", + "lastName": "Li", + }, + ], + "doi": "10.1016/j.jcrysgro.2011.12.035", + "journal": "Journal of Crystal Growth", + "month": "2", + "number": "1", + "pages": "27–33", + "title": "Growth evolution and microstructural characterization of semipolar (112̄2) GaN selectively grown on etched r-Plane sapphire", + "volume": "341", + "year": "2012", + }, + "input": String( + @article{Leung_2012, + author = {Leung, Benjamin and Sun, Qian and Yerino, Christopher and Zhang, Yu and Han, Jung and Hyun Kong, Bo and Koun Cho, Hyung and Liao, Kuan-Yung and Li, Yun-Li}, + year = {2012}, + month = feb, + volume = {341}, + pages = {27--33}, + doi = {10.1016/j.jcrysgro.2011.12.035}, + journal = {Journal of Crystal Growth}, + number = {1}, + title = {Growth Evolution and Microstructural Characterization of Semipolar (11\\\\=22) {{GaN}} Selectively Grown on Etched r-Plane Sapphire} + } + ), + "key": "Leung_2012", + "mode": Object { + "author": "creatorlist", + "doi": "verbatim", + "journal": "literal", + "month": "literal", + "number": "literal", + "pages": "literal", + "title": "title", + "volume": "literal", + "year": "literal", + }, + "type": "article", + }, + ], + "errors": Array [], + "jabref": Object { + "groups": Object {}, + "root": Array [], + }, + "preamble": Array [], + "strings": Object {}, +} +` diff --git a/tokenizer.ts b/tokenizer.ts index 76de8c418..8ce65f276 100644 --- a/tokenizer.ts +++ b/tokenizer.ts @@ -3,32 +3,17 @@ import moo from 'moo' // eslint-disable-next-line no-magic-numbers // const show = (obj: any): string => JSON.stringify(obj, null, 2).replace(/[\u007F-\uFFFF]/g, chr => `\\u${(`0000${chr.charCodeAt(0).toString(16)}`).substr(-4)}`) -type CharCategory = { - name: string - alias: string - isBmpLast: boolean - bmp: string -} - -const charCategories: CharCategory[] = require('xregexp/tools/output/categories') - -function char(cats: CharCategory[], extra?: string, neg=false): string { - return `[${neg ? '^' : ''}${cats.map(cat => cat.bmp).join('')}${extra || ''}]` -} - -const ciwLu: string = char(charCategories.filter(cat => cat.name === 'Lu')) -const ciwLl: string = char(charCategories.filter(cat => cat.name === 'Ll')) -export const connectedInnerWord = new RegExp(`-${ciwLu}${ciwLl}*(?=-|$)`, 'g') +import * as rx from './re' -const L: string = char(charCategories.filter(cat => cat.name === 'L')) -const LNM: string = char(charCategories.filter(cat => cat.name.match(/^[LNM]/)), '\u00AD\u2060') +const L: string = rx.match(rx.categories.filter(cat => cat.name === 'L')) +const LNM: string = rx.match(rx.categories.filter(cat => cat.name.match(/^[LNM]/)), '\u00AD\u2060') const W = `${LNM}*?${L}${LNM}*` -const B = `(?=(?:${char(charCategories.filter(cat => cat.name.match(/^[LNM]/)), '\u00AD\u2060').replace(/^./, '[^')}|$))` +const B = `(?=(?:${rx.match(rx.categories.filter(cat => cat.name.match(/^[LNM]/)), '\u00AD\u2060').replace(/^./, '[^')}|$))` const Word = new RegExp(`${W}${B}`) -const P = new RegExp(char(charCategories.filter(cat => cat.name.match(/^P/)))) +const P = new RegExp(rx.match(rx.categories.filter(cat => cat.name.match(/^P/)))) -const Lu: string = char(charCategories.filter(cat => cat.name === 'Lu'), '\u2060') +const Lu: string = rx.match(rx.categories.filter(cat => cat.name === 'Lu'), '\u2060') const Acronym = new RegExp(`(?:(?:(?:${Lu}[.]){2,}${B})|(?:(?:vs?[.])(?=[ \t\n\r\u00A0])))`) const Contraction = new RegExp(`${W}['’]${W}${B}`) @@ -68,9 +53,9 @@ const lexer = moo.compile({ }) const shaper: [RegExp, string][] = [ - [ new RegExp(char(charCategories.filter(cat => cat.name === 'Lu')), 'g'), 'X' ], - [ new RegExp(char(charCategories.filter(cat => cat.name.match(/^L[^Cu]/))), 'g'), 'x' ], - [ new RegExp(char(charCategories.filter(cat => cat.name[0] === 'N')), 'g'), 'd' ], + [ new RegExp(rx.match(rx.categories.filter(cat => cat.name === 'Lu')), 'g'), 'X' ], + [ new RegExp(rx.match(rx.categories.filter(cat => cat.name.match(/^L[^Cu]/))), 'g'), 'x' ], + [ new RegExp(rx.match(rx.categories.filter(cat => cat.name[0] === 'N')), 'g'), 'd' ], [ /’/g, "'" ], [ /–/g, '-' ], [ /[\u2060\u00AD]/g, '' ],