Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@
Thanks for your interest in contributing to `unicode`! We welcome new contributions regardless of your level of experience or familiarity with PureScript.

Every library in the Contributors organization shares a simple handbook that helps new contributors get started. With that in mind, please [read the short contributing guide on purescript-contrib/governance](https://github.com/purescript-contrib/governance/blob/main/contributing.md) before contributing to this library.

## Generating Internal Modules

The [Data.CodePoint.Unicode.Internal](../src/Data/CodePoint/Unicode/Internal.purs) and [Data.CodePoint.Unicode.Internal.Casing](../src/Data/CodePoint/Unicode/Internal/Casing.purs) modules can be generated with the following command from the root of this repository:

```sh
$ ./download.sh
$ ./ubconfc < UnicodeData.txt > src/Data/CodePoint/Unicode/Internal.purs
$ ./fullcase.js
$ purs-tidy format-in-place src/Data/CodePoint/Unicode/Internal.purs src/Data/CodePoint/Unicode/Internal/Casing.purs
```

(Note that this downloads data according to the version stored in the [`unicode-version`](../unicode-version) file in the root.)
15 changes: 0 additions & 15 deletions docs/README.md

This file was deleted.

51 changes: 30 additions & 21 deletions fullcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const keys = scKeys.concat(cfKeys).sort(sortHex);
const data = {};

const hex = a => a ? '0x'+a : '0';
const hexes = a => a ? '[' + a.split(' ').filter(b=>b).map(hex) + ']' : '[]';
const hexes = a => a ? '[ ' + a.split(' ').filter(b=>b).map(hex).join(', ') + ' ]' : '[]';

for (let code of keys) {
const d = { code: hex(code) };
Expand Down Expand Up @@ -70,19 +70,18 @@ import Data.CodePoint.Unicode.Internal (bsearch, uTowlower, uTowtitle, uTowupper
import Data.Maybe (Maybe(..))

type CaseRec =
{
code :: Int,
lower :: Array Int,
title :: Array Int,
upper :: Array Int,
fold :: Int,
foldFull :: Array Int
{ code :: Int
, lower :: Array Int
, title :: Array Int
, upper :: Array Int
, fold :: Int
, foldFull :: Array Int
}

rules :: Array CaseRec
rules = [
${lines.join(",\n ")}
]
rules =
${lines.map((v, i) => i ? ", " + v : "[ " + v).join("\n ")}
]

zeroRec :: Int -> CaseRec
zeroRec code = { code, lower: [], title: [], upper: [], fold: 0, foldFull: [] }
Expand All @@ -97,28 +96,38 @@ findRule code = case bsearch (zeroRec code) rules (Array.length rules) recCmp of

fold :: Int -> Int
fold code =
let folded = (findRule code).fold
in if folded == 0 then uTowlower code else folded
let
folded = (findRule code).fold
in
if folded == 0 then uTowlower code else folded

foldFull :: Int -> Array Int
foldFull code =
let folded = (findRule code).foldFull
in if Array.null folded then [uTowlower code] else folded
let
folded = (findRule code).foldFull
in
if Array.null folded then [ uTowlower code ] else folded

lower :: Int -> Array Int
lower code =
let lowered = (findRule code).lower
in if Array.null lowered then [uTowlower code] else lowered
let
lowered = (findRule code).lower
in
if Array.null lowered then [ uTowlower code ] else lowered

title :: Int -> Array Int
title code =
let titled = (findRule code).title
in if Array.null titled then [uTowtitle code] else titled
let
titled = (findRule code).title
in
if Array.null titled then [ uTowtitle code ] else titled

upper :: Int -> Array Int
upper code =
let uppered = (findRule code).upper
in if Array.null uppered then [uTowupper code] else uppered
let
uppered = (findRule code).upper
in
if Array.null uppered then [ uTowupper code ] else uppered
`;

fs.writeFileSync("src/Data/CodePoint/Unicode/Internal/Casing.purs", file);
2 changes: 1 addition & 1 deletion src/Data/CodePoint/Unicode/Internal.purs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Data/CodePoint/Unicode/Internal/Casing.purs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading