# Users pasting unformatted code results in unwanted styles

**URL:** <https://meta.discourse.org/t/users-pasting-unformatted-code-results-in-unwanted-styles/29120>\
**Category:** Product Support\
**Created:** [2015 年5 月 22 日 11:56 UTC](https://meta.discourse.org/t/users-pasting-unformatted-code-results-in-unwanted-styles/29120 "2015-05-22T11:56:27Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

作者： ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
发布日期： [2015 年5 月 23 日 10:33 UTC](https://meta.discourse.org/t/users-pasting-unformatted-code-results-in-unwanted-styles/29120/7 "2015-05-23T10:33:21Z")

</div>

For your particular site possibly an interesting approach would be to run all “text chunks” pasted in via 4-5 regexes. For PHPs case you could quite easily come up with a few regexes that would be very accurate at predicting that a chunk pasted in is PHP. Then the editor could auto wrap. This would not have any performance impact, but hooking it in would be a bit tricky.

A more general approach as proposed by @tDo may be a bit harder to come up with. Clearly if we ever shipped something like this it would have to be opt in.

---

_[View the full topic](https://meta.discourse.org/t/users-pasting-unformatted-code-results-in-unwanted-styles/29120)._
