Convert a slug to a title
496744
function slugToTitle (slug) {
  slug = slug.replace('.md', '').trim();
  return _s.titleize(_s.humanize(path.basename(slug)));
}
1105121
def slugify(text, sep='-'):
    """"""
    text = stringify(text)
    if text is None:
        return None
    text = text.replace(sep, WS)
    text = normalize(text, ascii=True)
    if text is None:
        return None
    return text.replace(WS, sep)
683179
public function getSlugForTitle($title)
    {
        $slug = Str::slug($title);
        $latestSlug = $this->model->whereRaw("slug RLIKE '^{$slug}(-[0-9]*)?$'")->latest()->value('slug');

        if ($latestSlug) {
            $pieces = explode('-', $latestSlug);
            $number = end($pieces);

            return $slug.'-'.($number + 1);
        }

        return $slug;
    }
1062684
def slug(cls):
        
        slug = cls.__name__.lower()
        if slug.endswith('view'):
            slug = slug[:-4]
        return slug
90952
def get_by_slug(slug):
        '''
        
        '''
        rec = TabTag.select().where(TabTag.slug == slug)
        if rec.count() > 0:
            return rec.get()
        return None
123014
def slugify(mapping, bind, values):
    
    for value in values:
        if isinstance(value, six.string_types):
            value = transliterate(value)
            value = normality.slugify(value)
        yield value
606197
def slugify(string):
    
    string = re.sub('[^\w .-]', '', string)
    string = string.replace(" ", "-")
    return string
1178637
public function getUri($title, $id = 0, $contenttypeslug = "", $fulluri = true, $allowempty = true, $slugfield = 'slug')
    {
        $contenttype = $this->getContentType($contenttypeslug);
        $tablename = $this->getContenttypeTablename($contenttype);
        $id = intval($id);
        $slug = $this->app['slugify']->slugify($title);

        // Don't allow strictly numeric slugs, unless allow_numeric_slugs options is set
        if (is_numeric($slug) && $contenttype['allow_numeric_slugs'] !== true) {
            $slug = $contenttype['singular_slug'] . "-" . $slug;
        }

        // Only add '{contenttype}/' if $full is requested.
        if ($fulluri) {
            $prefix = '/' . $contenttype['singular_slug'] . '/';
        } else {
            $prefix = '';
        }

        $fields = $this->getContentTypeFields($contenttypeslug);
        //check if the fieldname exists, otherwise use 'slug' as fallback
        if (!in_array($slugfield, $fields)) {
            $slugfield = 'slug';
        }

        $query = sprintf(
            "SELECT id from %s WHERE %s=? and id!=?",
            $tablename,
            $slugfield
        );

        $res = $this->app['db']->executeQuery(
            $query,
            [$slug, $id],
            [\PDO::PARAM_STR, \PDO::PARAM_INT]
        )->fetch();

        if (!$res) {
            $uri = $prefix . $slug;
        } else {
            for ($i = 1; $i <= 10; $i++) {
                $newslug = Html::trimText($slug, 127 - strlen($i), false) . '-' . $i;
                $res = $this->app['db']->executeQuery(
                    $query,
                    [$newslug, $id],
                    [\PDO::PARAM_STR, \PDO::PARAM_INT]
                )->fetch();
                if (!$res) {
                    $uri = $prefix . $newslug;
                    break;
                }
            }

            // otherwise, just get a random slug.
            if (empty($uri)) {
                $suffix = '-' . $this->app['randomgenerator']->generateString(6, 'abcdefghijklmnopqrstuvwxyz01234567890');
                $slug = Html::trimText($slug, 128 - strlen($suffix), false) . $suffix;
                $uri = $prefix . $slug;
            }
        }

        // When storing, we should never have an empty slug/URI. If we can't make a nice one, set it to 'slug-XXXX'.
        if (!$allowempty && empty($uri)) {
            $uri = 'slug-' . $this->app['randomgenerator']->generateString(6, 'abcdefghijklmnopqrstuvwxyz01234567890');
        }

        return $uri;
    }
348469
public static function prefixSlug(string $slug) : string
    {
        if (substr($slug, 0, strlen(self::MODULE_PREFIX)) !== self::MODULE_PREFIX) {
            $slug = self::MODULE_PREFIX . $slug;
        }

        if (strlen($slug) > 20) {
            $slug = substr($slug, 0, 20);
        }

        $slug = strtolower($slug);

        return $slug;
    }
1235213
def get_slug(self, language_code, lang_name):
        
        title = self.get_title(language_code, lang_name)
        assert title != ""

        title = str(title)  # e.g.: evaluate a lazy translation

        slug = slugify(title)
        assert slug != "", "Title %r results in empty slug!" % title
        return slug
186915
def camel_to_title(name):
    
    split = re.findall(r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)", name)
    ret = " ".join(split)
    ret = ret[0].upper() + ret[1:]
    return ret
1039232
def show_slug_with_level(context, page, lang=None, fallback=True):
    """"""
    if not lang:
        lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE)

    page = get_page_from_string_or_id(page, lang)
    if not page:
        return ''

    return {'content': page.slug_with_level(lang)}
1170617
def _slug_strip(self, value):
        
        re_sep = '(?:-|%s)' % re.escape(self.separator)
        value = re.sub('%s+' % re_sep, self.separator, value)
        return re.sub(r'^%s+|%s+$' % (re_sep, re_sep), '', value)
1142699
def slugify(s):
    
    s = strip_accents(s.replace("'", '').lower())
    return re.sub('[^a-z0-9]+', ' ', s).strip().replace(' ', '-')
309535
def slug(request, url):
    """"""
    page = None

    if url:
        for slug in url.split('/'):
            if not slug:
                continue
            try:
                page = Page.objects.get(slug=slug, parent=page)
            except Page.DoesNotExist:
                raise Http404
    else:
        try:
            page = Page.objects.get(slug='index', parent=None)
        except Page.DoesNotExist:
            return TemplateView.as_view(
                template_name='wafer/index.html')(request)

    if 'edit' in request.GET:
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return EditPage.as_view()(request, pk=page.id)

    if 'compare' in request.GET:
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return ComparePage.as_view()(request, pk=page.id)

    return ShowPage.as_view()(request, pk=page.id)
611704
public static function slug(string $slug): string
    {
        $lettersNumbersSpacesHyphens = '/[^\-\s\pN\pL]+/u';
        $spacesDuplicateHypens = '/[\-\s]+/';

        $slug = preg_replace($lettersNumbersSpacesHyphens, '', $slug);
        $slug = preg_replace($spacesDuplicateHypens, '-', $slug);
        $slug = trim($slug, '-');

        return mb_strtolower($slug, 'UTF-8');
    }
989983
def _slugify_internal_collection_name(self, json_repr):
        """"""
        collection = self._coerce_json_to_collection(json_repr)
        if collection is None:
            return None
        internal_name = collection['name']
        return slugify(internal_name)