It does not keep the markdown

I am using gpt3.5 and gpt4 in python and the chat does not keep the tex/html markdown as requested. For example, when I try to translate

<p> This is a test </p>

from English to Spanish, it does not keep the translation between <p></p>. I have a few htmls and I just want to translate them to other languages, and I don’t want to parse the html and parse it back. If it is not possible, is it easy to use beautifulsoup to keep the markdown but translate piece by piece?

Using ChatGPT with 3.5 model

Prompt

You work at translating text for HTML pages from English to Spanish. Translate the following HTML.

<p> This is a test </p>

Reply

<p> Esto es una prueba </p>


Note: To get the HTML to display correctly in the Markdown for this post, escaped the HTML from the prompt and the reply. The prompt and reply as used with ChatGPT were unescaped as would be expected.