Maintain tables from HTML email in when using HTML to Markdown

AI-generated summary

The discussion revolves around maintaining tables from HTML emails when using HTML to Markdown conversion in Discourse. Currently, tables get mangled and converted to plaintext. mcwumbly suggests skipping tables and maintaining them as HTML, while codinghorror mentions that Markdown table support might improve the situation.

vinothkannans explains that the issue lies in the server-side HTML to Markdown conversion, which doesn’t support Markdown tables yet. However, the client-side JavaScript conversion does support it. zogstrip proposes removing the Ruby version and replacing it with the JavaScript version to avoid code duplication.

Users brechtm and mcwumbly experience issues with tables breaking off messages during conversion. Editing and pasting raw HTML tables seems to work as a workaround. zogstrip mentions that tables will be properly converted once a specific PR is merged: https://github.com/discourse/discourse/pull/9586.

I was trying to advise a user on how they might import a Google Doc into Discourse as a new topic and suggested trying to copy/paste the doc into an email and then email it in. It mostly worked, but there were a few tables in the doc that got mangled in the process.

When an email into Discourse includes an HTML table, that table gets mangled and turned into plaintext on the Discourse side.

I have the incoming_email_prefer_html on as well as the “allow html tables” setting.

It’d be cool if tables were just skipped and maintained as HTML in that case. (Or perhaps there’s a table extension we’re planning on enabling once the markdown-it is in the mix?)

「いいね!」 7

This might work better now that we have more formal Markdown table support @vinothkannans?

Yes, it will work better if the user used copy-paste method instead of email-in workaround.

HTML pasting feature uses client side JavaScript for Markdown conversion. But for incoming emails we converting it in server side using our custom converter which doesn’t support Markdown tables yet.

「いいね!」 3

I see no point in duplicating our code in JS and Ruby. I will remove the Ruby version and replace it with the JS version.

「いいね!」 8

メールに表が含まれている場合、最初の表とそれに続く部分が Markdown への変換時に失われてしまいます。これによりメッセージが突然途切れてしまい、ユーザーにとって非常に混乱を招きます。ユーザーは小さな封筒アイコンをクリックすることで元の HTML メールを読むことはできますが、これはあまりユーザーフレンドリーではなく、おそらくバグとして扱われるべきでしょう。

メッセージを編集して、生 HTML の表を貼り付けるとうまく動作します。なぜ Markdown 変換時にこれを自動で行わないのでしょうか?

この PR がマージされると、テーブルが正しく変換されます :ok_hand:

「いいね!」 5