def clean(self, *args, **kwargs): """ RUS: Меняет шрифт текста в заголовке, подзаголовке, ЛИДе на шрифт Typograph. Ограничивает количество символов в заголовке до 90 знаков. """ self.title = Typograph.typograph_text(self.title, 'ru') if self.subtitle: self.subtitle = Typograph.typograph_text(self.subtitle, 'ru') if self.lead: self.lead = Typograph.typograph_text(self.lead, 'ru') max_length = getattr(settings, 'PUBLICATION_TITLE_MAX_LENGTH', 90) len_title = len(self.title) if len_title > max_length: raise ValidationError(_('The maximum number of characters {}, you have {}').format(max_length, len_title))
def assertText(self, text, *args, **kwargs): check_html = kwargs.pop('check_html', True) value = Typograph.typograph_text(text, self.lang, **kwargs) value_hl = highlight(value) if not value_hl in args: print('\n'+value_hl) for arg in args: print(arg) print('\n') self.assertIn(value_hl, args) if check_html: value2 = Typograph.typograph_html(value, self.lang) if value != value2: print('\n'+highlight(value)+'\n'+highlight(value2)) self.assertEqual(highlight(value), highlight(value2))
def assertText(self, text, *args, **kwargs): check_html = kwargs.pop('check_html', True) value = Typograph.typograph_text(text, self.lang, **kwargs) value_hl = highlight(value) if not value_hl in args: print('\n' + value_hl) for arg in args: print(arg) print('\n') self.assertIn(value_hl, args) if check_html: value2 = Typograph.typograph_html(value, self.lang) if value != value2: print('\n' + highlight(value) + '\n' + highlight(value2)) self.assertEqual(highlight(value), highlight(value2))
def do_typograph(context, value): return Typograph.typograph_text(value, context['lang'])