1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/fork-uslug
2023-02-26 12:37:29 +00:00
..
lib Tools: Use Yarn 3 to manage monorepo (#5833) 2021-12-20 15:08:43 +00:00
test Tools: Use Yarn 3 to manage monorepo (#5833) 2021-12-20 15:08:43 +00:00
index.js Tools: Use Yarn 3 to manage monorepo (#5833) 2021-12-20 15:08:43 +00:00
LICENSE Tools: Use Yarn 3 to manage monorepo (#5833) 2021-12-20 15:08:43 +00:00
package.json Releasing sub-packages 2023-02-26 12:37:29 +00:00
README.md Tools: Use Yarn 3 to manage monorepo (#5833) 2021-12-20 15:08:43 +00:00

Uslug.js


Modified for Joplin:

  • Added support for emojis - "🐶🐶🐶🐱" => "dogdogdogcat"

Permissive slug generator that works with unicode. We keep only characters from the categories Letter, Number and Separator (see Unicode Categories) and the common CJK Unified Ideographs as defined in the version 6.0.0 of the Unicode specification.

Inspired by unicode-slugify. Note that this slug generator is different from node-slug which focus on translating unicode characters to english or latin equivalent.

Quick Examples

uslug('Быстрее и лучше!') // 'быстрее-и-лучше'
uslug('汉语/漢語') // '汉语漢語'

uslug('Y U NO', { lower: false })) // 'Y-U-NO'
uslug('Y U NO', { spaces: true })) // 'y u no'
uslug('Y-U|NO', { allowedChars: '|' })) // 'yu|no'

Installation

npm install uslug

Options

uslug(string, options)

Generate a slug for the string passed.

Arguments

  • string - The string you want to slugify.
  • options - An optional object that can contain:
    • allowedChars: a String of chars that you want to be whitelisted. Default: '-_~'.
    • lower: a Boolean to force to lower case the slug. Default: true.
    • spaces: a Boolean to allow spaces. Default: false.

License

This project is distributed under the MIT License. See LICENSE file for more information.