Wrong links position in text from telegram post

Author: RedHotUnicornCreated May 4, 2024Updated Aug 13, 2026
Labelsbug

Hello!

Found an peculiarity in extracting text from telegram posts. So the link for example is here .

The text of the post is :

Interestingly, most people voted for Ukrainian to be the subject of my new post. So here you go — below is everything you wanted to know about the relationship of ...

In html file the link just in div:

xml
<div>
Interestingly, most people <a href="https://t.me/durov/271" target="_blank" rel="noopener" onclick="return confirm('Open this link?\n\n'+this.href);">voted</a> for Ukrainian to be the subject of my new post. So here you go — below is everything you wanted to know about the relationship of
...
</div>

But after extracting markdown text contains two \n before each link:

Interestingly, most people

voted for Ukrainian to be the subject of my new post. So here you go — below is everything you wanted to know about the relationship of

The code of extraction:

python
import trafilatura
url = "https://t.me/durov/272?embed=1&mode=tme"
html = trafilatura.fetch_url(url)

sent=trafilatura.extract(
    (
        html
    )
    , output_format='markdown'
    ,include_images=True
    # ,favor_precision=True
    ,include_formatting=True
    , include_links=True
)

print(sent)

I tried to use favor_precision option but its removing formatting and links.