Alir3z4 / Alir3z4/html2text

Ampersand in link causes different markdown to be generated vs. non-ampersand link

オープン
#441 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
2.2k
フォーク
296
PR マージ指標
30日以内にマージされた PR はありません

説明

Version: `html2text==2025.4.15`.

I want to rely on the behavior where `http://link/` gets rendered in Markdown as ``.

Unfortunately if the link contains an ampersand it renders using `[link](link)`, despite the link and text being exactly the same:

```python
>>> from html2text import HTML2Text as H
>>> h = H()

# good!
>>> h.handle('https://foo/')
'\n\n'

# an ampersand in the URL causes []() link syntax, but I guess that's expected since "&y" turns into "&y;"
>>> h.handle('https://foo/?x=1&y=2')
'[https://foo/?x=1&y;=2](https://foo/?x=1&y=2)\n\n'

# but even when & is escaped, and both link and text end up being exactly the same string, []() is still generated for the link
>>> h.handle('https://foo/?x=1&y=2')
'[https://foo/?x=1&y=2](https://foo/?x=1&y=2)\n\n'
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。