Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Apr 15, 2024
1 parent 2f158e0 commit 514bb13
Show file tree
Hide file tree
Showing 22 changed files with 1,785 additions and 25 deletions.
12 changes: 12 additions & 0 deletions re.ts
Original file line number Diff line number Diff line change
@@ -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')
8 changes: 7 additions & 1 deletion sentence-case.ts
Original file line number Diff line number Diff line change
@@ -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)}`)

Expand Down
11 changes: 11 additions & 0 deletions test/other/mid-word-capital.bib
Original file line number Diff line number Diff line change
@@ -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}
}
Original file line number Diff line number Diff line change
@@ -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 {},
}
`
Original file line number Diff line number Diff line change
@@ -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 {},
}
`
Original file line number Diff line number Diff line change
@@ -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 {},
}
`
Loading

0 comments on commit 514bb13

Please sign in to comment.