Skip to content

Commit

Permalink
More documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Coachonko committed Jun 15, 2023
1 parent 304747b commit f742333
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion slugify.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module slugify
import regex

pub struct SlugifyOptions {
mut:
mut:
// to_lower when true produces lowercase slugs.
to_lower bool
// max_length is the maximum number of characters allowed in the slug.
Expand Down
4 changes: 2 additions & 2 deletions slugify_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn test_slugify_make_lang() {
slugifier.lang = Language.no
assert slugifier.make('Har du røykt sokka dine?') == 'har-du-roeykt-sokka-dine'
slugifier.lang = Language.it
assert slugifier.make('Un € o un $') == "un-euro-o-un-dollaro"
assert slugifier.make('Un € o un $') == 'un-eur-o-un'
}

fn test_max_length() {
Expand All @@ -29,7 +29,7 @@ fn test_smart_truncate() {
assert slugifier.make('Sugma Willy: we are your fitness family.') == 'Sugma-Willy'
}

fn test_skip_transliteration(){
fn test_skip_transliteration() {
mut slugifier := SlugifyOptions{
transliterate: false
}
Expand Down
77 changes: 39 additions & 38 deletions substitutions.v
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,57 @@ const (
// When passing a different language to `make_lang`, any mapping found in the passed language will
// override the mappings in `en_sub`. Mappings that exist in `en_sub` but not in the passed language
// will still apply.
//
// Please note that some symbols are not only used for a single meaning. For example `£` is not only
// used for british pounds. In such cases it is best to use either more ambiguous replacement than
// `GBP` or none at all and let the character be removed.
//
// Replacements should only contain `\w` characters and hyphens `-`, any other character will be removed.
en_sub = {
'&': 'and'
'@': 'at'
'%': 'percent'
'<': 'less'
'>': 'greater'
'|': 'or'
// TODO some currency symbols are used for more than just one currency.
'€': 'euro'
'$': 'dollar'
'¢': 'cent'
'£': 'pound'
'¤': 'currency'
'¥': 'yen'
'฿': 'baht'
'₠': 'ecu'
'₢': 'cruzeiro'
'₣': 'french franc'
'₤': 'lira'
'₥': 'mill'
'₦': 'naira'
'₧': 'peseta'
'₨': 'rupee'
'₩': 'won'
'₪': 'new shequel'
'₫': 'dong'
'₭': 'kip'
'₮': 'tugrik'
'₯': 'drachma'
'₰': 'penny'
'₱': 'peso'
'₲': 'guarani'
'₳': 'austral'
'₴': 'hryvnia'
'₵': 'cedi'
'₸': 'kazakhstani tenge'
'₹': 'indian rupee'
'₺': 'turkish lira'
'₽': 'russian ruble'
'₿': 'bitcoin'
'؋': 'afghani'
'﷼': 'rial'
//
'€': 'EUR'
'¢': 'C'
'£': 'PS'
'¥': 'Y'
'฿': 'Bh'
'₠': 'ECU'
'₢': 'Cr'
'₣': 'FF'
'₤': 'L'
'₥': 'mil'
'₦': 'N'
'₧': 'Pts'
'₨': 'Rs'
'₩': 'W'
'₪': 'NS'
'₫': 'D'
'₭': 'K'
'₮': 'T'
'₯': 'Dr'
'₰': 'Pf'
'₱': 'P'
'₲': 'G'
'₳': 'A'
'₴': 'UAH'
'₵': 'C'
'₸': 'T'
'₹': 'Rs'
'₺': 'L'
'₽': 'R'
'₿': 'BTC'
'∆': 'delta'
'∑': 'sum'
'∞': 'infinity'
'♥': 'love'
'♥': 'heart'
}
fa_sub = {
'ک': 'kh'
'ی': 'y'
}
it_sub = {
'&': 'e'
Expand All @@ -80,7 +82,6 @@ const (
'<': 'minore'
'>': 'maggiore'
'|': 'o'
'$': 'dollaro'
}
nl_sub = {
'&': 'en'
Expand Down

0 comments on commit f742333

Please sign in to comment.