Ejemplo n.º 1
0
 def save(self, *args, **kwargs):
     body = self.body
     body = extract_images(body, self)
     body = clean_html(body, full=False)
     if settings.TEXT_AUTO_HYPHENATE:
         try:
             body = hyphenate(body, language=self.language)
         except (TypeError, CMSPlugin.DoesNotExist):
             body = hyphenate(body)
     self.body = body
     super(AbstractText, self).save(*args, **kwargs)
Ejemplo n.º 2
0
 def save(self, *args, **kwargs):
     body = self.body
     body = extract_images(body, self)
     body = clean_html(body, full=False)
     if settings.TEXT_AUTO_HYPHENATE:
         try:
             body = hyphenate(body, language=self.language)
         except (TypeError, CMSPlugin.DoesNotExist):
             body = hyphenate(body)
     self.body = body
     super(AbstractText, self).save(*args, **kwargs)
Ejemplo n.º 3
0
 def save(self, *args, **kwargs):
     # we need to save the plugin first and then save the updated body, otherwise
     # we cannot set the correct parent on extracted images
     super(AbstractText, self).save(*args, **kwargs)
     body = self.body
     body = extract_images(body, self)
     body = clean_html(body, full=False)
     if settings.TEXT_AUTO_HYPHENATE:
         try:
             body = hyphenate(body, language=self.language)
         except (TypeError, CMSPlugin.DoesNotExist):
             body = hyphenate(body)
     self.body = body
     kwargs['update_fields'] = ('body',)
     super(AbstractText, self).save(*args, **kwargs)
Ejemplo n.º 4
0
 def save(self, *args, **kwargs):
     # we need to save the plugin first and then save the updated body, otherwise
     # we cannot set the correct parent on extracted images
     kwargs['update_fields'] = ('body', )
     super(AbstractText, self).save(*args, **kwargs)
     body = self.body
     body = extract_images(body, self)
     body = clean_html(body, full=False)
     if settings.TEXT_AUTO_HYPHENATE:
         try:
             body = hyphenate(body, language=self.language)
         except (TypeError, CMSPlugin.DoesNotExist):
             body = hyphenate(body)
     self.body = body
     kwargs['update_fields'] = ('body', )
     super(AbstractText, self).save(*args, **kwargs)
Ejemplo n.º 5
0
 def save(self, *args, **kwargs):
     super(AbstractText, self).save(*args, **kwargs)
     body = self.body
     body = extract_images(body, self)
     body = clean_html(body, full=False)
     if settings.TEXT_AUTO_HYPHENATE:
         try:
             body = hyphenate(body, language=self.language)
         except (TypeError, CMSPlugin.DoesNotExist):
             body = hyphenate(body)
     self.body = body
     # no need to pass args or kwargs here
     # this 2nd save() call is internal and should be
     # fully managed by us.
     # think of it as an update() vs save()
     super(AbstractText, self).save(update_fields=('body',))
Ejemplo n.º 6
0
 def save(self, *args, **kwargs):
     super(AbstractText, self).save(*args, **kwargs)
     body = self.body
     body = extract_images(body, self)
     body = clean_html(body, full=False)
     if settings.TEXT_AUTO_HYPHENATE:
         try:
             body = hyphenate(body, language=self.language)
         except (TypeError, CMSPlugin.DoesNotExist):
             body = hyphenate(body)
     self.body = body
     # no need to pass args or kwargs here
     # this 2nd save() call is internal and should be
     # fully managed by us.
     # think of it as an update() vs save()
     super(AbstractText, self).save(update_fields=('body',))
Ejemplo n.º 7
0
def cached_softhyphen(value, language=None):
    """
    Hyphenates html and caches result.
    """
    md5 = hashlib.md5()
    md5.update(value.encode('utf-8'))
    digest = md5.hexdigest()
    hyph_html = cache.get("softhypen_cache_" + digest)
    if not hyph_html:
        hyph_html = hyphenate(value, language=language)
        cache.set("softhypen_cache_" + digest, 0)
    return mark_safe(hyph_html)
Ejemplo n.º 8
0
def softhyphen_filter(textitem, html):
    """
    Apply soft hyphenation to the text, which inserts ``­`` markers.
    """
    language = textitem.language_code

    # Make sure the Django language code gets converted to what django-softhypen 1.0.2 needs.
    if language == "en":
        language = "en-us"
    elif "-" not in language:
        language = "{0}-{0}".format(language)

    return hyphenate(html, language=language)
Ejemplo n.º 9
0
def softhyphen_filter(textitem, html):
    """
    Apply soft hyphenation to the text, which inserts ``­`` markers.
    """
    language = textitem.language_code

    # Make sure the Django language code gets converted to what django-softhypen 1.0.2 needs.
    if language == "en":
        language = "en-us"
    elif "-" not in language:
        language = "{0}-{0}".format(language)

    return hyphenate(html, language=language)
def softhyphen(value, language=None):
    """
    Hyphenates html.
    """
    return hyphenate(value, language=language)
Ejemplo n.º 11
0
def softhyphen(value, language="en-us"):
    """
    Hyphenates html.
    """
    return hyphenate(value, language=language)
 def text_cleaned(self):
     return hyphenate(self.text.replace(" ", " "), language="ru-ru")
 def populate_hyphenated_title(apps, schema_editor):
     EventPage = apps.get_model("events", "EventPage")
     for page in EventPage.objects.all():
         page.hyphenated_title = hyphenate(page.title, language="de-de")
         page.save()
Ejemplo n.º 14
0
 def save(self, *args, **kwargs):
     self.hyphenated_title = hyphenate(self.title, language="de-de")
     super().save(*args, **kwargs)
Ejemplo n.º 15
0
def softhyphen(value, language='de-de'):
    return mark_safe(hyphenate(value, language=language))
Ejemplo n.º 16
0
def softhyphen(value, language=None):
    """
    Hyphenates html.
    """
    return hyphenate(value, language=language)
Ejemplo n.º 17
0
def softhyphen(value, language="en-us"):
    """
    Hyphenates html.
    """
    return mark_safe(hyphenate(value, language=language))
Ejemplo n.º 18
0
from softhyphen.html import hyphenate

print hyphenate("<h1>I love hyphenation</h1>")
Ejemplo n.º 19
0
 def populate_hyphenated_title(apps, schema_editor):
     BasePage = apps.get_model("core", "BasePage")
     for page in BasePage.objects.all():
         page.hyphenated_title = hyphenate(page.title, language="de-de")
         page.save()
Ejemplo n.º 20
0
def justice(env, value, language='en-us'):
	return hyphenate(value, language=language)