Why does the sourcecode tag chew up formatted source code?

  • Unknown's avatar

    Starting a month or so ago, the sourcecode tag began working erratically. *After* saving and previewing a post (scheduled for a future date), WP sometimes replaces all the line ends with br / tags, so that the source code block appears as a single line about half a mile long.

    There is no way to reproduce this on command, but it’s chewing up my sourcecode blocks on a fairly regular basis. Reviewing the scheduled posts doesn’t help, as the change occurs randomly behind the scenes, even though I don’t edit the post.

    We worked through a situation like this a year ago and it took a long time to convince you that the hole was in your end of the boat and caused by a change in how you handled sourcecode tags. If it’s at all possible, I’d like to fast-forward beyond that exhange this time, as it looks like you’ve tweaked the sourcecode handler again. [grin]

    Thanks…

    The blog I need help with is: (visible only to logged in users)

  • Hi Ed – I found the old ticket that Jeremy opened, and I’m not able to reproduce that issue anymore, so this does seem like a different, new issue.

    Can you provide a bit more detail about what’s happening now? For example:

    1. In the Visual Editor, add the following:

    [sourcecode]
    & >> 
    [/sourcecode]

    2. Preview post.
    3. Schedule post.
    Etc.

    I understand it doesn’t happen consistently, but clear steps like that will give me a starting point. Also, if you can get screenshots of the before-and-after, that’d be a help. Here are instructions for how to make a screenshot: http://en.support.wordpress.com/make-a-screenshot/

    You can upload it to your blog’s Media Library and I can look at it there. Thanks very much for your patience with this.

  • Unknown's avatar

    Also, if you can get screenshots of the before-and-after, that’d be a help.

    OK, here’s an upcoming post that’s been pretty well chewed on.

    In chronological order, the screenshots are:

    Preview
    Editor – visual
    Editor – text

    The damage to the first one evidently consumed the closing /sourcecode tag, which was there when I finished previewing the post. When I was done, it looked just fine, all the sourcode sections were intact, and the page saved without complaint.

    When I attempted to edit the post today (I always do some proofreading & cleanup, which is why I keep a week or two of posts in the queue), the entire post turned to mush in the editor. I’ve seen that happen before, but it’s rare enough that I’ve never tried to report the problem. The screenshot:

    Trashed post

    Switching back and forth from visual to text mode usually straightens things out, but sometimes not.

    Hope that helps you get it sorted out…

    Thanks!

  • Hi Ed – Thanks very much for the screenshots, this was helpful. I played around with this for awhile and the good news is, I managed to reproduce it. But the bad news is, I only reproduced it once, and I have no idea what I did differently that time, and I couldn’t reproduce it again. ;)

    I’m asking around for additional feedback on this. In the meantime, if you continue to notice this happening, any additional details you can provide that might help us reproduce it consistently would be great.

  • Unknown's avatar

    I have no idea what I did differently that time, and I couldn’t reproduce it again. ;)

    There’s a lot of that going on here, too, although I’m glad it’s not all in my head…

    I’ll fix up that post and report back when it blows up again.

    Thanks!

  • Unknown's avatar

    Here’s a post scheduled for the last day of the year; the listing went from normal to gibberish when I previewed the post; there’s an embedded br / tag between every line.

    Shredded sourcecode – post scheduled for 31 December 2013

    After I clicked the Preview button, the shredded sourcecode appeared in both the Visual Editor and the preview. I had done a few saves & previews before, so something went wrong that doesn’t usually happen.

    I’ll fix this on 30 December and hope the revision sticks…

  • Hi Ed – Thanks, I see what you mean. I’ve asked our developers to take a look at it, and I’ll let you know what they say.

  • Unknown's avatar

    Ah, so that was you: I saw somebody editing that post, which was a bit startling. Eventually I figured out what was going on.

    I’ll repair that post now. The next few weeks will have many posts with sourcecode tags; I hope all goes well with the debugging!

    Thanks!

  • Hi, Ed. Just wanted to let you know that we’re still working on reproducing this issue, so far without any luck. The closest I’ve come so far has been to reproduce in preview only for a scheduled post. Even that doesn’t happen with any regularity. We’ve checked that we haven’t changed the shortcode code itself since the last fix we applied, so there’s some other gremlin in the works here.

    I’d be curious to learn whether the issue reproduces using markdown (fairly recently enabled on wordpress.com and possibly, though not certainly, at issue here). If you’d like to test it, instructions for enabling it can be found here. I’ll of course be looking into the markdown code to see if there’s any likelihood that it’s the culprit.

    Meanwhile, if you can keep trying to zoom in on a set of reliable reproduction steps, we’ll try to do the same.

  • Unknown's avatar

    > a set of reliable reproduction steps

    One thing I do, which you probably don’t, is flipping between the Visual and Text editors on a regular basis while editing a post: there’s no other way to insert code tags.

    I don’t want to switch to Markdown, as it looks like there’s no fine-grained control over images and listings, which are important to me. Adding images looks particularly awkward, at best, as I’m generally uploading original files as I write the post; Markdown would toss all the automatically generated tags & suchlike.

    I haven’t put up much code in the last couple of weeks, but that’s about to change. You’ll be the second to know when trouble crops up… (grin)

  • Unknown's avatar

    Another anomaly has popped up that I cannot explain: something in the editor occasionally inserts random span tags.

    I created & scheduled a post today that incurred some damage:

    https://softsolder.wordpress.com/2014/01/18/2000-toyota-sienna-replacing-the-bank-1-sensor-2-oxygen-sensor/?preview=true

    In the preview, you’ll notice some odd line spacing; use the Text editor and you’ll find span tags in the first and last paragraph, surrounding random chunks of text… including a single space.

    This doesn’t involve any sourcecode tags or anything pasted from other sources; it’s pure typed text in the Visual editor.

    I’ve seen this before, so it’s not new news.

    I can leave that post unchanged until Friday, the day before it goes live; let me know when you’re done poking at it.

  • Unknown's avatar

    Here’s another post with the mysterious span and font settings added to the fourth paragraph:

    https://softsolder.wordpress.com/2014/01/16/free-motion-quilting-darning-foot-modification-the-home-shop-way/?preview=true

    Remember that I’m just typing text into the Visual editor, not pasting text from another source. I don’t have any way to reproduce this problem on command, but it’s definitely happening more frequently!

    That post goes live on Thursday; I’ll repair it tomorrow…

  • Unknown's avatar

    And another one:

    https://softsolder.wordpress.com/2014/01/24/bent-tap-huh/?preview=true

    I think that should suffice to show the problem; I’ll start repairing them as I find them…

  • Hmm, from a quick glance, it looks like the span tags are being wrapped around new content you’re adding to the end of a paragraph. Is this consistent with your observations about the phenomenon? I’ve found a bug report for TinyMCE in WordPress core that can add span tags to lists especially when the browser is zoomed and the right (or wrong) steps are taken. It’s entirely possible that there’s a similar issue that your workflow is triggering. So the more we know about anything consistent about the workflow in posts in which this happens, the better chance we stand of sorting out a cause.

    I’m going to ask our resident TinyMCE expert if he knows of any outstanding issues with the spans, but as always, a set of consistent reproduction steps would be most helpful if you can manage them. I’ve tried reproducing in a number of ways (various combinations of typing, deleting, toggling from visual to text, zooming, etc.) with no luck so far.

  • Unknown's avatar

    wrapped around new content you’re adding to the end of a paragraph

    In this case:
    https://softsolder.wordpress.com/2014/01/16/free-motion-quilting-darning-foot-modification-the-home-shop-way/?preview=true

    The span tag appeared after twiddling the first part of the paragraph and leaving the last sentence alone, if I’m reading the revision history correctly.

    So it’s not clear that any particular sequence triggers it, other than going back and editing the text… which I just can’t stop myself from doing! [grin]

    I’m using Chromium, but I’d be hard-pressed to say anything about zoom levels and suchlike; they may vary to suit whatever else pops up in other tabs.

  • Just to make sure I’ve got it straight — you’re generally typing and not pasting in these cases, right?

  • Unknown's avatar

    Yup, for many of the paragraphs that seem to be chewed up, it’s all typing… and backspacing … and deleting and …

    I’ve seen several cases where two separate span tags neatly bracket a single space between words. I have no idea what’s going on there, but I surely didn’t change that space and, if I changed the text on both sides, it would happen at different times.

    I do paste code blocks, for obvious reasons, but those don’t necessarily happen anywhere near the inserted span tags… and in some of the damaged posts, there isn’t any code!

  • Well, I heard back from our TinyMCE expert and he reports that this is probably an issue we can’t really do much with, unfortunately. Webkit browsers in particular are apparently getting more and more aggressive about tweaking text formatting by adding spans. We do lots of tricks to try to keep this from being an issue, but we’re sort of out of tricks. Ever hear of the whack-a-mole game? :) It’s not an answer I like to give, but for now at least, the only workaround is to use a different browser or perhaps to switch back to text mode and snip out any offending tags before the final save.

  • Unknown's avatar

    Erk & similar remarks.

    I’ll give it a go with Firefox again, but that’s the one producing the most sourcecode problems; perhaps those have Gone Away by now.

    I’ll fix up the outstanding posts, cross my fingers, and hope for the best.

    Thanks for the help!

  • Unknown's avatar

    OK, so I switched back to Firefox, which (so far) hasn’t injected any bogus span tags. Alas, it just trashed a lengthy sourcecode block by inserting bogus br / tags after each line.

    So I can’t use Chromium because it wrecks text entries.

    I can’t use Firefox because it wrecks source code.

    I’m running Linux, so IE isn’t an option.

    Are there any mainstream browsers that actually work dependably with whatever software stack you’re using to make blog posts happen?

    I like WordPress and appreciate your efforts, don’t get me wrong, but something is badly broken when I can’t post a simple entry without your infrastructure chewing on the text…

  • The topic ‘Why does the sourcecode tag chew up formatted source code?’ is closed to new replies.