Giter Site home page Giter Site logo

raku-text-slugify's Introduction

Build Status

NAME

Text::Slugify - create a URL slug from text.

SYNOPSIS

    use Text::Slugify;

    my $txt;

    $txt = "This is a test ---";
    slugify $txt; 
    #=> «this-is-a-test»

    $txt = 'C\'est déjà l\'été.';
    slugify $txt;
    #=> «c-est-deja-l-ete»

    $txt = 'jaja---lol-méméméoo--a';
    slugify $txt, :max-length(9);
    #=> «jaja-lol»

For more examples, have a look at the test file (t/basic.t6).

DESCRIPTION

Text::Slugify is a module to slugify text. It takes a piece of text, removes punctuation, spaces and other unwanted characters to produce a string suitable for use in a URL.

INSTALLATION

Using zef:

zef update && zef install Text::Slugify

From source:

git clone https://github.com/khalidelboray/raku-text-slugify.git
cd raku-text-slugify && zef install .

SUBROUTINES

The module exports the following subroutines:

slugify

    sub slugify(
        Str:D $text is copy,            # Text to be slugified.
        Int:D :$max-length = 0,         # Output string length.
        :$separator = "-",              # Separator between words.
        :$regex-pattern = Nil,          # Regex pattern for allowed characters in output text.
        :@stopwords = [],               # Words to be discounted from output text.
        :@replacements = [],            # List of replacement rule pairs e.g. ['|'=>'or', '%'=>'percent']
        Bool:D :$entities = True, 
        Bool:D :$decimal = True, 
        Bool:D :$hexadecimal = True, 
        Bool:D :$word-boundary = False, 
        Bool:D :$lowercase = True,      # Set case sensitivity by setting it to False.
        Bool:D :$save-order = False,    # If True and max-length > 0 return whole words in the initial order.
    )

smart-truncate

    sub smart-truncate(
        Str:D $string is rw,             # String to be modified.
        Int:D :$max-length = 0,          # Output string length.
        Bool:D :$word-boundary = False,  
        Str:D :$separator = " ",         # Separator between words.
        Bool:D :$save-order = False,     # Output text's word order same as input.
    )

NOTE: To import the subroutine smart-truncate or strip alongside slugify into your code, use use Text::Slugify :ALL.

CREDIT-REFERENCE

This module is mostly based on Python Slugify.

This is my fork of https://gitlab.com/uzluisf/raku-text-slugify

raku-text-slugify's People

Contributors

khalidelboray avatar uzluisf avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

limkokholefork

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.