# メールのトリミング改善（コードブロック内のトリミングなし）

**URL:** <https://meta.discourse.org/t/email-trimming-improvement-no-trimming-in-code-blocks/320159>\
**Category:** Feature\
**Tags:** email\
**Created:** [2024 年 8 月 5 日午後 12:25 UTC](https://meta.discourse.org/t/email-trimming-improvement-no-trimming-in-code-blocks/320159 "2024-08-05T12:25:48Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![ZLMarshall](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zlmarshall/32/423027_2.png) [@ZLMarshall](https://meta.discourse.org/u/ZLMarshall)\
**Post date:** [2024 年 8 月 5 日午後 12:25 UTC](https://meta.discourse.org/t/email-trimming-improvement-no-trimming-in-code-blocks/320159/1 "2024-08-05T12:25:48Z")

</div>

これもGitHubでissueを立てましたが、より多くの人が見ている可能性があるので、こちらにも投稿しておきます。

> <https://github.com/discourse/email_reply_trimmer/issues/21>
>
> We're using a pretty standard setup of Discourse with email integration, and it …looks like even within code blocks the trimming rules are applied. So for example in an email containing:
> 
> \`\`\`
> \# This should not be deleted
> \#
> \# Or trimmed
> \# It is code
> \####
> Code code code
> \`\`\`
> 
> Everything below the first '#' is trimmed. That's a bit inconvenient, as many folks use comment markers to break sections of their code, sometimes even in multi-line strings for printing. Is there any chance this is a common enough issue that someone might have a moment to see if it could be improved? I've gotten as far as the regex where the matching happens, but I'm not sure how complex adding an exception for code blocks would be.
> 
> Thanks,
> Zach

コードブロック内でのトリミングを避けるように、メールのトリミングロジックを改善できれば素晴らしいと思います。例えば、以下のようなメールの場合：

````plaintext
```
# これは削除されるべきではありません
#
# またはトリミングされるべきではありません
# コードです
####
コード コード コード
```
````

最初の「#」より下のすべてがトリミングされてしまいます。これは少し不便です。なぜなら、多くの人がコードのセクションを区切るためにコメントマーカーを使用しており、印刷のために複数行の文字列にさえ使用することがあるからです。また、人々がプログラムの出力をメールにコピー＆ペーストしたい場合に、その出力にそのような行が含まれていても、プログラムの出力が引用符で囲まれていれば、メールはそれらの行でトリミングされないという便利な機能もあります。これが十分に一般的な問題であるため、誰かが改善できるかどうかを確認する時間がある可能性はありますか？正規表現のマッチングが行われる箇所まではたどり着きましたが、コードブロックの例外を追加するのがどれほど複雑になるかはわかりません。

よろしくお願いします！

---

_[View the full topic](https://meta.discourse.org/t/email-trimming-improvement-no-trimming-in-code-blocks/320159)._
