Giter VIP home page Giter VIP logo

limax's Introduction

limax

(Yet another) Node.js module to generate URL slugs, also known as clean URLs, user-friendly URLs and SEO-friendly URLs.

The difference?

This module extends the fantastic speakingurl module to include Romanisation of Chinese and Japanese scripts.

Give it a string of text in pretty much any major world language and it will convert it to valid characters, conforming to RFC3986, for use within the path element of a URL.

Currently supports, but not limited to, the following scripts:

  • Latin: e.g. English, français, Deutsch, español, português
  • Cyrillic: e.g. русский язык, български език, українська мова
  • Chinese: e.g. 官话, 吴语 (converts to Latin script using Pinyin with optional tone number)
  • Japanese: e.g. ひらがな, カタカナ (converts to Romaji using Hepburn)

If you already use either the speakingurl or slug modules, you can probably swap in limax without changing the logic in your code.

Oh, and limax is the Latin word for slug.

Install

npm install limax

Usage

import slug from 'limax';

slug(text)

const latin = slug('i ♥ latin'); // i-love-latin
const cyrillic = slug('Я люблю русский'); // ya-lyublyu-russkij
const pinyin = slug('我爱官话'); // wo3-ai4-guan1-hua4
const romaji = slug('私は ひらがな が大好き'); // ha-hiragana-gaki

slug(text, options)

options:

  • replacement: String to replace whitespace with, defaults to - (provides API compatibility with the slug module)
  • separator: String, equivalent to replacement (provides API compatibility with the speakingurl module)
  • lang: String, ISO 639-1 two-letter language code, defaults to auto-detected language
  • tone: Boolean, add tone numbers to Pinyin transliteration of Chinese, defaults to true
  • separateNumbers: Boolean, separate numbers that are within a word, defaults to false
  • separateApostrophes: Boolean, separate apostrophes that are within a word, defaults to false
  • maintainCase: Boolean, maintain the original string's casing, defaults to false
  • custom:
    • Object, custom map for translation, overwrites all i.e. { '&': '#', '*': ' star ' }
    • Array, add chars to allowed charMap
const strich = slug('Ich ♥ Deutsch', {lang: 'de'}); // ich-liebe-deutsch
const unterstreichen1 = slug('Ich ♥ Deutsch', {lang: 'de', replacement: '_'}); // i_liebe_deutsch
const unterstreichen2 = slug('Ich ♥ Deutsch', {lang: 'de', separator: '_'}); // i_liebe_deutsch
const wuYin = slug('弄堂里的菜品赤醬', {tone: false}); // nong-tang-li-di-cai-pin-chi-jiang

// separateNumbers example
const numbersInWord = slug('hello2world'); // hello2world
const numbersSeparated = slug('hello2world', { separateNumbers: true }); // hello-2-world

// separateApostrophes example
const apostrophesInWord = slug('j\'aime'); // jaime
const apostrophesSeparated = slug('j\'aime', { separateApostrophes: true }); // j-aime

// maintainCase example
const caseNotMaintained = slug('HelloWorld'); // helloworld
const caseMaintained = slug('HelloWorld', { maintainCase: true }); // HelloWorld

// custom example
const custom1 = slug('hello.world', { custom: ['.'] }); // hello.world
const custom2 = slug('hello-*-world', { custom: { '*': 'asterisk' } }); // hello-asterisk-world

slug(text, replacement)

Provided to support backwards-compatibility with the slug module.

const underscore = slug('i ♥ unicode', '_'); // i_love_unicode

Test .github/workflows/ci.yml

Run the unit tests with:

npm test

Contribute

Pull requests with mappings and tests for further scripts and languages are more than welcome.

Licence

Copyright 2013 Lovell Fuller and others.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

limax's People

Contributors

arjanfrans avatar betree avatar brooooooklyn avatar ddtraceweb avatar dvrylc avatar gamebear64 avatar keithyeh avatar lovell avatar lumaxis avatar starcsb avatar wonknu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

limax's Issues

Deprecation warnings when trying to install limax

A lot of deprecation warnings when I trying to install limax.

See here for more details:

CXX(target) Release/obj.target/nodejieba/lib/index.o
In file included from ../lib/index.cpp:1:
In file included from ../lib/nodejieba.h:4:
../lib/utils.h:56:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value su(val);
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
1 warning generated.
  CXX(target) Release/obj.target/nodejieba/lib/nodejieba.o
In file included from ../lib/nodejieba.cpp:1:
In file included from ../lib/nodejieba.h:4:
../lib/utils.h:56:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value su(val);
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:15:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value dictPath(info[0]->ToString());
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:16:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value modelPath(info[1]->ToString());
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:17:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value userDictPath(info[2]->ToString());
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:18:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value idfPath(info[3]->ToString());
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:19:21: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  String::Utf8Value stopWordsPath(info[4]->ToString());
                    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:42:19: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string word = *(String::Utf8Value(info[0]->ToString()));
                  ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:46:15: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
      tag = *(String::Utf8Value(info[1]->ToString()));
              ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:97:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:114:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:127:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:140:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:157:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:173:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../lib/nodejieba.cpp:189:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
  string sentence = *(String::Utf8Value(info[0]->ToString()));
                      ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/USER/USERNAME/.node-gyp/10.3.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))

Chinese Pinyin doesn't work on Google/Firebase Cloud Functions

The following return empty string if run on Google/Firebase Cloud Functions (Node12)

const slug = require('limax');
slug('金山芋圓王')

I suspect is due to @napi-rs/pinyin. Switching to version v2.1.0 seems to work as it uses pinyin.

Possible to fallback to pinyin if @napi-rs/pinyin import fail?

Unsupported languages

Hi there,

Is there a solution to have a backup slug for all the languages that limax doesn't support?

Few exemple that I have in mind
"하용수" / "🌴🍰🌕💋🍪" / "▲"

Thanks!

Problem with installing on nodejs v.0.12.9

We are using your module in project with nodejs v.0.12.9.

Your dependency pinyin v2.7.0 begin to use ES6 witch is not supported in nodejs v.0.12.9 and we have a problem with installing limax.

Please solve this problem or we will use our fork in future.

Apostrophe in the custom option is ignored

Expected behavior:

>limax("wendy's", {custom: ["'"]})
wendy's

Actual behavior:

>limax("wendy's", {custom: ["'"]})
wendys

The separateApostrophes option does not help here.

how replace ' by -

i try this

slug("j'aime ça", custom: { "'": "-" }}) and i have //jaime-ca

i would like have //j-aime-ca

thanks,

Getting "limax_1.default is not a function"

In a typescript, NestJS project I'm getting:

limax_1.default is not a function

On this code:

import slug from 'limax'

slug(name)

The generated JS code looks like this:

const limax_1 = require("limax");

limax_1.default(name)

Slugified emoji turns out as an empty string

Hi, thanks for this awesome library!

We've faced a situation with strings only made of emojis.

Actual behavior

limax('😵️') === ''

Expected behavior

// Replace by emoji name
limax('😵️') === 'dizzy_face'

// Or by emoji code (as when pasted as an URL in the browser)
limax('😵️') === 'xn--w38h'

Limax returning strange string for UUID

Limax is transforming UUIDs in a weird way:

slug('​​​​​1d5502f9-ae2b-430d-82ba-9589adf25673​​​​​') //  '1-d5502f-9-ae-2-b-430-d-82-ba-9589-adf-25673​​​​​'

Chinese Pinyin is not accurate

I use limax to display some chinese pinyin, but I found the result of chinese pinyin is not accurate, for example:

const pinyin = slug('路上的行人'); // lu4-shang4-de-hang2-ren2
// The correct result of above should be // lu4-shang-de-xing2-ren2

I suggest to replace pinyin by pinyin-pro, because pinyin-pro has higher accuracy, better performance, and no dependencies.

The accuray about chinese pinyin of pinyin-pro is 99.744%, and pinyin is only 97.844%. You can see the comparsion

client side?

How well does this work client side?

I was using node-slug but on the client side it requires a 2MB file for utf8 characters to load which isn't realistic.

Build Errors

Hi @lovell,

I'm seeing build errors with the latest version of limax and its dependencies, and was hoping you could help me get them resolved.

The errors seem to be in nodejieba, which is a dependency of the pinyin package implemented in cdb8d59

Full debug output:

> [email protected] install /Users/Jed/Development/packages/keystone/node_modules/keystone-utils/node_modules/limax/node_modules/pinyin/node_modules/nodejieba
> node-gyp rebuild

  CXX(target) Release/obj.target/nodejieba/lib/index.o
In file included from ../lib/index.cpp:1:
In file included from ../lib/nodejieba.h:4:
../lib/utils.h:17:11: error: use of undeclared identifier 'NanIntern'
  array = NanIntern::Factory<v8::Array>::New(ov.size());
          ^
../lib/utils.h:17:39: error: expected '(' for function-style cast or type construction
  array = NanIntern::Factory<v8::Array>::New(ov.size());
                             ~~~~~~~~~^
../lib/utils.h:17:42: error: no member named 'New' in the global namespace
  array = NanIntern::Factory<v8::Array>::New(ov.size());
                                       ~~^
../lib/utils.h:19:21: error: use of undeclared identifier 'NanIntern'
      array->Set(i, NanIntern::Factory<v8::String>::New(ov[i].c_str()));
                    ^
../lib/utils.h:19:50: error: expected '(' for function-style cast or type construction
      array->Set(i, NanIntern::Factory<v8::String>::New(ov[i].c_str()));
                                       ~~~~~~~~~~^
../lib/utils.h:19:53: error: no member named 'New' in the global namespace
      array->Set(i, NanIntern::Factory<v8::String>::New(ov[i].c_str()));
                                                  ~~^
../lib/utils.h:24:11: error: use of undeclared identifier 'NanIntern'
  array = NanIntern::Factory<v8::Array>::New(ov.size());
          ^
../lib/utils.h:24:39: error: expected '(' for function-style cast or type construction
  array = NanIntern::Factory<v8::Array>::New(ov.size());
                             ~~~~~~~~~^
../lib/utils.h:24:42: error: no member named 'New' in the global namespace
  array = NanIntern::Factory<v8::Array>::New(ov.size());
                                       ~~^
../lib/utils.h:30:19: error: use of undeclared identifier 'NanIntern'
    array->Set(i, NanIntern::Factory<v8::String>::New(ss.str().c_str()));
                  ^
../lib/utils.h:30:48: error: expected '(' for function-style cast or type construction
    array->Set(i, NanIntern::Factory<v8::String>::New(ss.str().c_str()));
                                     ~~~~~~~~~~^
../lib/utils.h:30:51: error: no member named 'New' in the global namespace
    array->Set(i, NanIntern::Factory<v8::String>::New(ss.str().c_str()));
                                                ~~^
../lib/utils.h:35:11: error: use of undeclared identifier 'NanIntern'
  array = NanIntern::Factory<v8::Array>::New(ov.size());
          ^
../lib/utils.h:35:39: error: expected '(' for function-style cast or type construction
  array = NanIntern::Factory<v8::Array>::New(ov.size());
                             ~~~~~~~~~^
../lib/utils.h:35:42: error: no member named 'New' in the global namespace
  array = NanIntern::Factory<v8::Array>::New(ov.size());
                                       ~~^
../lib/utils.h:41:19: error: use of undeclared identifier 'NanIntern'
    array->Set(i, NanIntern::Factory<v8::String>::New(ss.str().c_str()));
                  ^
../lib/utils.h:41:48: error: expected '(' for function-style cast or type construction
    array->Set(i, NanIntern::Factory<v8::String>::New(ss.str().c_str()));
                                     ~~~~~~~~~~^
../lib/utils.h:41:51: error: no member named 'New' in the global namespace
    array->Set(i, NanIntern::Factory<v8::String>::New(ss.str().c_str()));
                                                ~~^
18 errors generated.
make: *** [Release/obj.target/nodejieba/lib/index.o] Error 1

Custom map not working properly

hello,when i use Chinese symbols as the custom map key, doesn't seem to be working

const key3 = limax('你好~', { separator: '-', tone: false, custom: {
    '~': '~',
} })

exception: ni-hao-~
actually: ni-hao

Mention mongoose-slug-plugin use with limax?

Using this package for generating slugs to use in URL's is probably fairly common. I'd suggest possibly putting a note in README such as...

Using Mongoose? Try mongoose-slug-plugin at https://github.com/ladjs/mongoose-slug-plugin!

Or something similar - the reason being is because a lot of Node.js users use MongoDB (Mongo is to Node.js what SQL is to Ruby imo). And the most popular ODM for MongoDB is Mongoose, therefore I figured it'd help out with confusion (considering there's dozens of poorly maintained, untested, and unpluggable slug helpers on NPM right now for Mongoose).

Custom replacement doesn't probably work with non-latin chars

const options = { custom: ["."] };

const wrong = "中文.pdf";
console.log(limax(wrong, options)); // produces `zhong1-wen2-pdf`

const correct = "chinese.pdf";
console.log(limax(correct, options)); // produces `chinese.pdf`

It doesn't convert dot to dot as it is supposed to do. Am I missing something?

Macron should default to non-macron character not hyphen

Characters with a marcron (e.g. ō) should default to the non-macron version of that letter, not a hyphen.

Example: Pōneke

  • Expected result: poneke
  • Current result: p-neke

I'm interested in making a contribution to the repo if maintainers agree on the intent of this issue!

truncate from speakingurl lib

Quick question, the speakingurl lib allows you to specify a truncate number but limax doesn't expose that. Is that intentional? Would you be open to have that added back.

I am not sure I need it yet but as I was evaluating the different libs I noticed that difference.

pinyin tone numbers

Hi All,

As a common practice, China pinyin urls don't include the tone numbers.

We wonder if the url slug need the tone numbers, e.g.
http://www.haopinyin.com/

And the following e.g.:

弄堂里的菜品赤醬

// instead of 
nong4-tang2-li3-di2-cai4-pin3-chi4-jiang4

// should be
nong-tang-li-di-cai-pin-chi-jiang

// or even be (though not readable for foreigners; and can be managed by separator parameter)
nongtanglidicaipinchijiang

Should we change the limax pinyin module?

This issue refer to :
keystonejs/keystone#1366 (comment)

Numbers inside a word

slug('test22test')

This returns: test-22-test. I would expect this to return test22test. Looks like this is related to the regex mentioned in #12.

Is this intended behavior? And if so, why?

Add a changelog on release?

Currently if users got the release tab they have no clue what's changed between releases.

Any chance you could start adding those?

Number slugs

I've realised that slugs involving numbers behave a little weirdly.

> limax('12')
'12'

> limax('123')
'1-2-3'

> limax('12345')
'1-234-5'

Is this the intended behavior and if so, why?
Thanks!

I need to make slug 特殊天-1 --> te-shu-tian-1

Hi,
I using this library for making slug in our app. But I'm getting the issue when I try making a slug of
"特殊天-1"
my expected result is te-shu-tian-1
but the actual output is te-shu-tian1

Please advice

Win10 x64, doesn't compile

C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNot
ifyHook2': redefinition; different type modifiers [D:\mycompany\mycompany2\myproduct\node_modules\nodejieba\build\nodej
ieba.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNot
ifyHook2'
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd D:\mycompany\mycompany2\myproduct\node_modules\nodejieba
gyp ERR! node -v v5.6.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: node-gyp rebuild
npm WARN install:[email protected] Exit status 1

typedefs!

would be great to have type definitions for TS

Bug: limax blocks loading of angular4/webpack/aot app on iOS + Safari on MacOS

My app works well on Chrome/Firefox/Edge/IE11 on Window 10 and MacOS but doesn't load on any browser tested on iOS 9.3.5 nor on Safari on MacOS, as mentioned.

No error is produced unfortunately, which makes it difficult to narrow. I spent 10 hours finding out, trying many hints: polyfill, angular versions 4.0.0, 4.0.1, 4.0.2 and many others.

I used this project as a starter, that load without limax and doesn't with it:
https://github.com/vladotesanovic/angular2-express-starter

I'm an amateur dev and still have a lot to learn, so I may be mistaken here, but this ought to be reproducible. Let me know if you need more details.

Should we separateNumbers by default?

I don't think this is what most users intend to have as output (e.g. foo123foo => foo-123-foo) - and other packages like slug, speakingurl, etc do not do this by default as far as I know.

Mapping of umlauts broken

Hi all,

previous versions of Limax mapped German umlauts to the proper counterpart (e.g. ü will become ue). With the change in #44 and 4.0 unfortunately this breaks, and ü will now be mapped to a simple u which would be considered “less correct” in German.

Also, trying to fix it via a custom mapping will not help, as the _.deburr replacement happens without considering the given mappings. Our current workaround replaces them before applying limax:

  const fixedMapping = {
    ä: 'ae',
    Ä: 'Ae',
    ö: 'oe',
    Ö: 'Oe',
    ü: 'ue',
    Ü: 'Ue'
  };
  let fixedInput = input;
  for (const mapping of Object.entries(fixedMapping)) {
    fixedInput = fixedInput.replaceAll(mapping[0], mapping[1]);
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.