Alir3z4 / html2text

Convert HTML to Markdown-formatted text.
alir3z4.github.io/html2text/
GNU General Public License v3.0
1.74k stars 266 forks source link

`.handle()` w/ new text yields previous results if AssertionError is raised #400

Open Antsthebul opened 1 year ago

Antsthebul commented 1 year ago

When using the same HTML2Text instance, the failure is presisted through future valid strings. Items that it tries to prepend the old text to the new text

Failing

test = "Hellow<![]-->world"
test2="Goodbye"

h = HTML2Text()

try:
    print(h.handle(test))
except AssertionError:
    h.handle(test2)

ouput

[...]    raise AssertionError(
AssertionError: expected name token at "<![]-->worldGoodbye"

Working

test = "Hellow<![]-->world"
test2="Goodbye"

h = HTML2Text()
try:
    print(h.handle(test))
except AssertionError:
    print("pass")

output

pass