Problems with [sourcecode] tags.

I find there is a problem editing posts and comments which contain sourcecode tags.

I have posted about this problem at the WordPress Support Forums.

Here is some Python code that is a solution to Enigma 1646.

from fractions import Fraction
from collections import Counter

ms = Counter()
for x in range(15, 255, 15):
  for y in range(0, 195, 15):
    ms[Fraction(y - 80, x)] += 1

print(len([m for m in ms.values() if m > 1]))

The problem is when presented in the editor the line:

[sourcecode language="python"]

is presented as:

[sourcecode language=""python""]

Notice that the double quotes around python, become duplicated. Unless this is resolved manually before saving the comment, it will be messed up when displayed.

I will now reproduce the code in a comment, and then edit it and add one additional line at the end.

Advertisements

About Jim Randell

Hacking Python for fun.
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Problems with [sourcecode] tags.

  1. jimrandell says:

    Here is the same code posted in a comment. It displays as it does in the main post until edited.

    from fractions import Fraction
    from collections import Counter

    ms = Counter()
    for x in range(15, 255, 15):
    for y in range(0, 195, 15):
    ms[Fraction(y – 80, x)] += 1

    print(len([m for m in ms.values() if m > 1]))

    Update: I am now editing the post just to add this content after the code. In the editor the quotes around the value for the language attribute to the sourcecode tag were presented doubled (i.e. there where two sets of double quotes around the value python). I have not corrected this manually. As you can see when the comment is updated the code does not display correctly.

  2. Jim Randell says:

    Editing comments from the “Dashboard” using “Quick Edit” is one way to avoid this (although it’s very tempting to use the little (Edit) link next to a comment you are viewing, but that launches you into the comment editor, which seems to be where the problem is).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s