#!/usr/bin/env python3
# SAT: a jabber client
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see
a paragraph
spam spam SPAM!test retest
toto
test retest
toto
'
expected = ""
try:
d = self.text_syntaxes.convert(
source,
self.text_syntaxes.SYNTAX_XHTML,
self.text_syntaxes.SYNTAX_MARKDOWN,
)
except plugin_misc_text_syntaxes.UnknownSyntax:
raise SkipTest("Markdown syntax is not available.")
d.addCallback(self.assertEqual, expected)
return d
def test_removeXHTMLMarkups(self):
expected = """ a link another link a paragraph secret EVIL! of EVIL! Password: annoying EVIL! spam spam SPAM! """
result = self.text_syntaxes._removeMarkups(self.EVIL_HTML1)
self.assertEqual(re.sub(r"\s+", " ", result).rstrip(), expected.rstrip())
expected = """test retest toto"""
result = self.text_syntaxes._removeMarkups(self.EVIL_HTML2)
self.assertEqual(re.sub(r"\s+", " ", result).rstrip(), expected.rstrip())