├── categories ├── Cc │ └── regex.mjs ├── Z │ └── regex.mjs ├── Cf │ └── regex.mjs ├── P │ └── regex.mjs └── S │ └── regex.mjs ├── .gitignore ├── properties └── Any │ └── regex.mjs ├── rollup.config.mjs ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── index.mjs ├── test ├── cjs.js └── test.mjs ├── README.md ├── package.json ├── update.mjs ├── LICENSE.txt └── CHANGELOG.md /categories/Cc/regex.mjs: -------------------------------------------------------------------------------- 1 | export default /[\0-\x1F\x7F-\x9F]/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | build/ 4 | *.log 5 | -------------------------------------------------------------------------------- /categories/Z/regex.mjs: -------------------------------------------------------------------------------- 1 | export default /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/ -------------------------------------------------------------------------------- /properties/Any/regex.mjs: -------------------------------------------------------------------------------- 1 | export default /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/ -------------------------------------------------------------------------------- /rollup.config.mjs: -------------------------------------------------------------------------------- 1 | export default [ 2 | { 3 | input: 'index.mjs', 4 | output: { 5 | file: 'build/index.cjs.js', 6 | format: 'cjs' 7 | } 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /categories/Cf/regex.mjs: -------------------------------------------------------------------------------- 1 | export default /[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/ -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: daily 7 | 8 | - package-ecosystem: npm 9 | directory: / 10 | schedule: 11 | interval: daily 12 | allow: 13 | - dependency-type: production 14 | -------------------------------------------------------------------------------- /index.mjs: -------------------------------------------------------------------------------- 1 | import Any from './properties/Any/regex.mjs'; 2 | import Cc from './categories/Cc/regex.mjs'; 3 | import Cf from './categories/Cf/regex.mjs'; 4 | import P from './categories/P/regex.mjs'; 5 | import S from './categories/S/regex.mjs'; 6 | import Z from './categories/Z/regex.mjs'; 7 | 8 | export { Any, Cc, Cf, P, S, Z }; 9 | -------------------------------------------------------------------------------- /test/cjs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | /* eslint-env mocha */ 3 | 4 | const ucm = require('../') 5 | const assert = require('assert') 6 | 7 | describe('CJS', () => { 8 | it('require', () => { 9 | assert.ok(ucm.Any) 10 | assert.ok(ucm.Cc) 11 | assert.ok(ucm.Cf) 12 | assert.ok(ucm.P) 13 | assert.ok(ucm.Z) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: '0 0 * * 3' 8 | 9 | jobs: 10 | test: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [ '18' ] 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Use Node.js ${{ matrix.node-version }} 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: ${{ matrix.node-version }} 25 | 26 | - run: npm install 27 | 28 | - name: Test 29 | run: npm test 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uc.micro 2 | 3 | [![CI](https://github.com/markdown-it/uc.micro/actions/workflows/ci.yml/badge.svg)](https://github.com/markdown-it/uc.micro/actions/workflows/ci.yml) 4 | [![NPM version](https://img.shields.io/npm/v/uc.micro.svg?style=flat)](https://www.npmjs.org/package/uc.micro) 5 | 6 | > Micro subset of unicode data files for [markdown-it](https://github.com/markdown-it) projects. 7 | 8 | Content of this repo is autogenerated from `unicode-` package, 9 | maintained by [Mathias Bynens](https://github.com/mathiasbynens). 10 | 11 | That's just a proxy to reduce dependencies/install size. 12 | 13 | **This package content is ONLY for [markdown-it](https://github.com/markdown-it) 14 | projects needs. Don't ask to extend it!** 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uc.micro", 3 | "version": "2.1.0", 4 | "description": "Micro subset of unicode data files for markdown-it projects.", 5 | "repository": "markdown-it/uc.micro", 6 | "license": "MIT", 7 | "main": "build/index.cjs.js", 8 | "module": "index.mjs", 9 | "exports": { 10 | ".": { 11 | "require": "./build/index.cjs.js", 12 | "import": "./index.mjs" 13 | }, 14 | "./*": { 15 | "require": "./*", 16 | "import": "./*" 17 | } 18 | }, 19 | "files": [ 20 | "index.mjs", 21 | "categories/", 22 | "properties/", 23 | "build/" 24 | ], 25 | "scripts": { 26 | "test": "npm run build && mocha", 27 | "build": "rollup -c", 28 | "update": "node update.mjs && npm test", 29 | "prepublishOnly": "npm run build" 30 | }, 31 | "devDependencies": { 32 | "@unicode/unicode-15.1.0": "^1.5.2", 33 | "mocha": "^10.2.0", 34 | "rollup": "^4.6.1", 35 | "shelljs": "^0.8.5" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/test.mjs: -------------------------------------------------------------------------------- 1 | import assert from 'node:assert' 2 | import * as ucm from '../index.mjs' 3 | 4 | describe('Unicode classes', () => { 5 | it('Any', () => { 6 | assert.ok(ucm.Any.test('A')); 7 | assert.ok(!ucm.Any.test('')); 8 | }); 9 | 10 | it('Cc', () => { 11 | assert.ok(ucm.Cc.test('\r')); 12 | assert.ok(!ucm.Cc.test('A')); 13 | }); 14 | 15 | it('Cf', () => { 16 | assert.ok(ucm.Cf.test('\xAD')); 17 | assert.ok(!ucm.Cf.test('A')); 18 | }); 19 | 20 | it('P', () => { 21 | assert.ok(ucm.P.test(',')); 22 | assert.ok(!ucm.P.test('A')); 23 | }); 24 | 25 | it('S', () => { 26 | assert.ok(ucm.S.test('$')); 27 | assert.ok(ucm.S.test('£')); 28 | assert.ok(ucm.S.test('€')); 29 | assert.ok(!ucm.S.test('A')); 30 | assert.ok(!ucm.S.test('')); 31 | assert.ok(!ucm.S.test(',')); 32 | }); 33 | 34 | it('Z', () => { 35 | assert.ok(ucm.Z.test(' ')); 36 | assert.ok(ucm.Z.test('\u2028')); 37 | assert.ok(ucm.Z.test('\u2029')); 38 | assert.ok(!ucm.Z.test('A')); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /update.mjs: -------------------------------------------------------------------------------- 1 | import shell from 'shelljs' 2 | import { mkdir, readFileSync, writeFileSync } from 'fs' 3 | 4 | const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url))) 5 | 6 | const upkgName = Object.keys(pkg.devDependencies).find(k => /@unicode/.test(k)); 7 | const upkgPath = `node_modules/${upkgName}`; 8 | 9 | console.log(upkgPath); 10 | 11 | shell.rm('-rf', 'properties'); 12 | shell.rm('-rf', 'categories'); 13 | 14 | function pick(from, to) { 15 | shell.mkdir('-p', to); 16 | const src = readFileSync(`${from}/regex.js`, 'utf8'); 17 | const out = src.replace('module.exports=', 'export default '); 18 | writeFileSync(`${to}/regex.mjs`, out, 'utf8'); 19 | } 20 | 21 | pick(`${upkgPath}//Binary_Property/Any`, 'properties/Any/'); 22 | pick(`${upkgPath}//General_Category/Control`, 'categories/Cc/'); 23 | pick(`${upkgPath}//General_Category/Format`, 'categories/Cf/'); 24 | pick(`${upkgPath}//General_Category/Separator`, 'categories/Z/'); 25 | pick(`${upkgPath}//General_Category/Punctuation`, 'categories/P/'); 26 | pick(`${upkgPath}//General_Category/Symbol`, 'categories/S/'); 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright Mathias Bynens 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2.1.0 / 2024-03-02 2 | ------------------ 3 | 4 | - Added symbol (`S`) catogiry. 5 | 6 | 7 | 2.0.0 / 2023-12-01 8 | ------------------ 9 | 10 | - Rewrite to ESM. 11 | - Unicode update to 15.1.0 12 | 13 | 14 | 1.0.6 / 2019-01-31 15 | ------------------ 16 | 17 | - Unicode update to 10.0.0. 18 | - Fixed `Z` content (added missed line and paragraph seperators), #10. 19 | 20 | 21 | 1.0.5 / 2018-01-26 22 | ------------------ 23 | 24 | - Remove outdated license info from readme (missed in previous update). 25 | 26 | 27 | 1.0.4 / 2018-01-26 28 | ------------------ 29 | 30 | - Unicode update to 10.0.0. 31 | - Clarified license, should be MIT, #6. 32 | 33 | 34 | 1.0.3 / 2016-09-14 35 | ------------------ 36 | 37 | - Unicode update to 9.0.0. 38 | - Rewrite update script (use npm instead of Makefile). 39 | - Added integrity tests. 40 | 41 | 42 | 1.0.2 / 2015-06-24 43 | ------------------ 44 | 45 | - License info clarify, #3. 46 | 47 | 48 | 1.0.1 / 2015-05-30 49 | ------------------ 50 | 51 | - Update to Unicode 8.+. 52 | - Also automatically fix possible ReDOS in `Any`, if source used to generate 53 | patterns like `(Any)+`. 54 | 55 | 56 | 1.0.0 / 2015-03-10 57 | ------------------ 58 | 59 | - Export all in index.js. 60 | 61 | 62 | 0.1.0 / 2015-02-22 63 | ------------------ 64 | 65 | - First release. 66 | -------------------------------------------------------------------------------- /categories/P/regex.mjs: -------------------------------------------------------------------------------- 1 | export default /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/ -------------------------------------------------------------------------------- /categories/S/regex.mjs: -------------------------------------------------------------------------------- 1 | export default /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/ --------------------------------------------------------------------------------