Preserving Javascript and other code blocks in posts
-
I use inline javascript and php sometimes in posts and I’m not a big fan of how WordPress can’t seem to leave these blocks alone when it comes to wpautop and wptexturize. When code within script or php tags gets messed with by these functions, it often breaks. I have the text-control plug-in which allows me to turn off both wpautop and wptexturize on a post-by-post basis, but really, this is not ideal.
Given that there is pretty much never *any* circumstance where text within script or php blocks should be touched by formatting functions, it seems to me that one of two things should happen (hopefully as a standard part of WordPress) —
1. wpautop and wptexturize should be improved such that they ignore at least script tags and possibly php tags, and even better a configurable array of tags. Basically, nothing within these tags should get touched and they shouldn’t be wrapped in p tags either.
2. There should be some sort of “no-op” markup you can add to posts which prevents wpautop and wptexturize from touching what’s inside. So, for instance, you could manually wrap a script tag in specially designated HTML comments which would tell formatting functions to lay off.
- The topic ‘Preserving Javascript and other code blocks in posts’ is closed to new replies.