def handleMatch(self, m): label = m.group(2).strip() url = resolve("wiki", self.project.slug, slugify(label)) if m.group(3): title = m.group(3).strip()[1:] else: title = label a = etree.Element("a") a.text = title a.set("href", url) a.set("title", title) a.set("class", "reference wiki") return a
def handleMatch(self, m): label = m.group(2).strip() # `project` could be other object (!) slug = getattr(self.project, "slug") if not slug: project = getattr(self.project, "project") slug = getattr(project, "slug") if not slug: return url = resolve("wiki", slug, slugify(label)) if m.group(3): title = m.group(3).strip()[1:] else: title = label a = etree.Element("a") a.text = title a.set("href", url) a.set("title", title) a.set("class", "reference wiki") return a
def test_slugify_3(): assert slugify(None) == ""
def test_slugify_2(): assert slugify("TestExamplePage") == "testexamplepage"
def test_slugify_1(): assert slugify("漢字") == "han-zi"
def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(self.title, self.__class__) super().save(*args, **kwargs)
def save(self, *args, **kwargs): if not self.href: self.href = slugify(self.title) super().save(*args, **kwargs)