Alir3z4 / Alir3z4/html2text

Character reference replacement results in raw HTML

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

説明

As a result of #109, character and entity references are unconditionally dereferenced. This causes HTML which contains character references representing HTML-like text to be converted to markdown with raw HTML by html2text 2017.10.4 and later:

$ echo "

Horizontal rule is <hr>

" | html2markdown
Horizontal rule is

To make the problem clearer, consider round-tripping from HTML to Markdown back to HTML:

$ echo "

Horizontal rule is <hr>

" | html2markdown | cmark

Horizontal rule is

$ echo "

Horizontal rule is <hr>

" | html2markdown | cmark --unsafe

Horizontal rule is


The conversion to markdown changes the meaning of the content by dereferencing the character references.

To satisfy the request in #109, I suggest preserving character and entity references which would be interpreted as [Raw HTML](https://spec.commonmark.org/0.30/#raw-html) if dereferenced. That would avoid producing unnecessary character references (as requested in #109) and also avoid changing the meaning of the content when it contains HTML-like text.

Thanks for considering,
Kevin

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

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

評価

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

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

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