Giter VIP home page Giter VIP logo

sluj's Introduction

Sluj

Sluj is a very small library for converting strings of UTF-16 text to slugs. A slug is a piece of text that is URL safe. Sluj can translate a wide variety of characters, including but not limited to cyrillic, and japanese characters.

This library adheres to the following:

Shout out to Trott/slug for inspiring me to make this over a rainy weekend.

Clojars

Clojars Project

This project is available on Clojars, and you can add it to your lein project via:

[com.github.rawleyfowler/sluj "1.0.2"]

Why?

Currently the most starred Slug clojure project is abandoned by the maintainer, plus it has dependencies. I thought that I could make it better, so I set out on this project.

Contributing

Particularly looking for contributions to the locale settings of the project, as there is no way I could create a locale for every alphabet myself. Also, the library needs a little work in the multi-byte characters department.

Examples

;; Simple examples
(sluj "Hey it's me!") ;; => hey-its-me
(sluj "25 ways to pet a cat") ;; => 25-ways-to-pet-a-cat

;; UTF-16 examples
(sluj "I ♥ Unicode!") ;; => i-unicode
(sluj "I ♥ Unicode!" :♥ "love") ;; => i-love-unicode

(sluj "Turn this ship 200°!") ;; => turn-this-ship-200
(sluj "Turn this ship 200 °!""degrees") ;; => turn-this-ship-200-degrees

;; Non english characters
;; These were made with google translate, sorry in advanced.
;; Default locale is Russian for Cyrillics
(sluj "маленький подъезд") ;; => malenkij-poduezd

;; Change the locale if you wish
(sluj "маленький подъезд" :locale "bg") ;; => malenykiy-podaezd

;; Change sparator
(sluj "hi mom" :separator "%") ;; => hi%mom

;; Pass the charmap as a argument
(sluj "I have weird characters ☢ ♥" :charmap {:♥ "heart" :☢ :radiate}) ;; => i-have-weird-characters-radiate-heart
;; Alternatively
(sluj "I have weird characters ☢ ♥" :♥ "heart" :☢ "radiate") ;; => i-have-weird-characters-radiate-heart

;; Change the casing
(sluj "make me upper" :casing "upper") ;; => MAKE-ME-UPPER

License

This project is licensed via the MIT license. Please read through the LICENSE file at the root of the project for more information.

sluj's People

Contributors

funkschy avatar rawleyfowler 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

Watchers

 avatar  avatar

Forkers

funkschy

sluj's Issues

NullPointerException on the following code

(-> s
        (string/replace #"[:/?#\[\]@!$&'()*+,;=]" "") ;; Remove any reserved RFC 3986 characters
        (replace-characters charmap) ;; Replace the characters with the charmap characters
        (extract-words) ;; Extract the words to a list of words
        (string/join separator) ;; Replace spaces with the separator
        casing))) ;; Apply the specified casing

For some reason, replace-characters throws a null pointer exception for s. I have no idea, how, or why, since replace-characters works perfectly fine in the repl, and on its own. This goes for all of the functions.

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.