def convert_to_amp(value): """ Converts HTML to AMP. """ if isinstance(value, RichText): value = richtext(value.source) return mark_safe(utils.convert_to_amp(value))
def test_img_processing(self): """ Test to verify img tags are converted to amp-img tags. """ processed_html = convert_to_amp(self.unprocessed_img_html, pretty=False) self.assertEqual(processed_html, self.processed_amp_img_html)
def richtext_amp(value): if isinstance(value, RichText): value = richtext(value.source) else: value = richtext(value) value = utils.convert_to_amp(value) return mark_safe(value)
def test_iframe_processing(self): """ Test to verify iframe tags are converted to amp-iframe tags. """ processed_html = convert_to_amp(self.unprocessed_iframe_html, pretty=False) print(self.processed_amp_iframe_html) print(processed_html) self.assertEqual(processed_html, self.processed_amp_iframe_html)
def amp_formatting(value): return mark_safe(utils.convert_to_amp(value))