Code for Fun!!

Leave a Reply to Wesley R. Elsberry Cancel Reply

Comment as a guest.

  1. Pingback: diGit Blog
  2. Just installed it. I really like the new option to show the plaintext code right in the codebox as well as the ability to have code in the comments.

    I am experiencing the following issues however.

    1. Settings reset when changing plugins. This has been mentioned in previous posts. If I go to the Syntax Highlighter plugin options and set Show Language name and Show Line Numbers to false, then go to my WP plugins page and active a plugin that is not currently on, Syntax Highlighter will forget my settings.

    2. language=”javascript” is not needed on the javascript links, in fact it can cause pages to not validate. I have already removed them from my own files, I suggest you remove them from the release.

    3. Look at this URL:
    http://www.projectarcanum.com/archive/2006/02/16/popular-posts-with-mint/#comment-114

    The equal sign (=) in the code gets whited out. I have narrowed this down to when I turn off “Show Line Numbers”. If I leave that as on, the equal appears. This also only seems to effect equals in the comments.

    5. With this same URL, if you click Plain Text the box collapses, changing in size so that only the first line is visible.

    4. If you try to validate the above URL:
    http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.projectarcanum.com%2Farchive%2F2006%2F02%2F16%2Fpopular-posts-with-mint%2F

    You will see that the syntax highlighter is inserting an end paragraph tag where this is no one open. Again, this problem only appears when “Show Line Numbers” is set to false.

    Aside from these bugs the new version is great. I can answer any questions you have about my setup, hopefully we can get these bugs licked.

  3. Settings reset when changing plugins. This has been mentioned in previous posts. If I go to the Syntax Highlighter plugin options and set Show Language name and Show Line Numbers to false, then go to my WP plugins page and active a plugin that is not currently on, Syntax Highlighter will forget my settings.

    Yes that’s been mentioned before but when I tested it on my WP2.0.1 test install, I wasn’t able to recreate this issue. I tried activating & deactivating a lot of plugins & never did the settings of iG:Syntax Hiliter change to default. Perhaps you can email me your WP admin username & password and I can look into what’s going on.

    The equal sign (=) in the code gets whited out. I have narrowed this down to when I turn off “Show Line Numbers”. If I leave that as on, the equal appears. This also only seems to effect equals in the comments.

    Again, this problem seems to be related to your styles. As you can see in this screenshot, switching off line numbers doesnot affect the code in anyway. πŸ™‚

    if you click Plain Text the box collapses, changing in size so that only the first line is visible

    That is a problem, seems like its there only with codeboxes having a line or two of code. I can’t brew a fix for this, except that we can use “min-height” CSS property but then that applies to only Opera & FireFox, not IE. Other way I can think of about it is to use a fixed height which again wouldn’t be cool!! If you’ve any suggestions, feel free to convey them!!

    You will see that the syntax highlighter is inserting an end paragraph tag where this is no one open. Again, this problem only appears when “Show Line Numbers” is set to false.

    Well, the plugin doesn’t add any paragraph tags nor does it close them. That might be WordPress doing it!! Its because of you not using proper indentation of your code, because if you did then in the blank line you’ll have atleast 1 tab(every code editor I’ve used does this by default) which wouldn’t make WordPress think that its an end of a paragraph & so it won’t try to close it & start a new paragraph in the next code line. However when you have the Line Numbers enabled, then all your code is put in an ordered list which would prevent WordPress from putting in paragraphs at the end of a line as each line in that case is put in as a list item. Nothing I can do about it!! πŸ™‚

  4. I will email you my login information so you can try and diagnose the settings reset problem. (note: its not like I expect you to fix it, its just that if looking at my site can help i would be happy to help).

    Did you notice what I said about your javacsript?

    Anyway, first to the paragraph thing. You were right about it being wordpress and about putting an indent on blanklines fixing it up! Thanks!

    About the plain text collapse, its happening because sPlainCodeHTML in the javascript is not calculating the height value properly. I’m not good at javascript, so I dont know why. But I know its generating values too small, like 8px height for 3 lines of code. Even in a long box of code, it doesnt generate a high enough number to encompass the entire block of plain code.

    A css way to deal with it would be to use min-height and height for IE. IE (6 and below) incorrectly treat height as min-height anyway. So if you did somethink like:
    .syntax_hilite textarea {
    min-height: x !important;
    }
    * html .syntax_hilite textarea {
    height: x !important;
    }
    It would work as wanted in all browsers. I think the important is necessary as linked stylesheets are less priority then inline styles.

    But what would you set the min-height too? I think the best solution is to figure out how to make the javascript work well.

    Actually I just played around with min-height and it only helps so much. Another wierd thing about this is that the browser isn’t creting a vertical scroll bar within the text area. Its like it thinks its the correct size.

    Would using the correct dom methods rather then innerHTML help perhaps? I would love to find a solution to this because I prefer the inplace plain text option very much.

    About the dissapearing equal sign, it was indeed a style problem. I apologize, I am usually good about catching those.

  5. OK, I emailed you my information. If you don’t get it feel free to contact me directly. Hopefully it will be of use to you figuring out the settings problem. If you need anymore information from me, feel free to ask.

    Thanks for listening to my problems! I always feel bad when I point out problems that aren’t really the fault of whoever I am pointing them out too!

  6. Did you notice what I said about your javacsript?

    Yes, I did note that, but its a trival thing. It’ll be taken care of in the next update.

    About the plain text collapse, its happening because sPlainCodeHTML in the javascript is not calculating the height value properly. I’m not good at javascript, so I dont know why. But I know its generating values too small, like 8px height for 3 lines of code. Even in a long box of code, it doesnt generate a high enough number to encompass the entire block of plain code.

    Yeah, that’s right!! I’ll look into it.

    Would using the correct dom methods rather then innerHTML help perhaps?

    If you can point me to a link with some reference on what that will be, then I might look into it, since when I was doing this “Plain Text” feature, I did read up a bit on what to use and went with innerHTML since its supported by almost all browsers. First I tried a hand at using innerText but then not many support it, so I went with innerHTML & stripped out HTML tags from it.

    I would love to find a solution to this because I prefer the inplace plain text option very much.

    I prefer it as well, the reason it being a default option & also on my blog!! πŸ˜‰

    About the dissapearing equal sign, it was indeed a style problem. I apologize, I am usually good about catching those.

    No problem, we all make mistakes!! πŸ™‚

    OK, I emailed you my information.

    Got it & I’ve checked your blog, its not resetting all options, just 2-3 of them. I’ll look into it!!

    Thanks for listening to my problems! I always feel bad when I point out problems that aren’t really the fault of whoever I am pointing them out too!

    No problem, the less bugs the better it is. Saves others a lot of trouble!! πŸ˜‰

  7. About the settings reset, I was poking around in syntax_hilite.php and I think the problem has to be with igSynHilite_Install(), as all the values that reset are all the ones that are set to ‘true’ in the $igSHOptionsArr array. So somewhere in there its not respecting if the options have been changed to false. I can poke around more, but being familiar with the code you would probably have more success.

    About the javascript issue, like I said I suck with javascript, but one time I was having an issue with a clients site at work as it had to be served application/xhtml+xml which forces compatable browsers into a strict mode where innerHTML doesnt work (actually, in the new firefox, it would). So I had to look at alternatives to innerHTML. I can’t seem to find the page right now, but I believe you have to use createElement(), createElementNS(), createTextNode(), appendChild(). You can try searching Google for “xhtml innerhtml”. Sorry I can’t be more help on this. Javascript is my weakest language.

  8. Hmmm…about the Javascript problem, perhaps it relates to the usage of a textarea. I just replaced the textarea with a div and now the sizing problem doesnt exist! There is a new problem of all the lines being dropped onto one line, but that could be solved by converting the ‘n’ newlines into linebreaks.

    Would that work? What was your reason for using a textarea, to avoid having to encode any html?

    I have something else you could look at if you want. Its only loosely related to Syntax Highliter, so feel free to ignore it. I use wp-print to produce print pages of my posts, like here:
    http://www.projectarcanum.com/archive/2006/02/16/popular-posts-with-mint/print/

    The syntax highlighted code looks pretty ugly in there, so I wanted to show plain text. What I did is modify wp-print so that before anything like wptexturize() or wpautop() can fire on the content, I use a preg_match borrowed from Syntax Highlighter to find any code blocks. I then do two things. First, I strip the code block of the starting and ending tags (

    , for example) so that Syntax Highlighter doesnt fire. Then I run htmlentities() on the content between the blocks and insert it back into the main content

    It works well as you can see in the linked post, with the only exception that it removes indents. Can you think of a way to make the indents work?

    Actually, this could potentially help Syntax Highlighter. If we can create a plain text that works within a div and not a text area, then we can ditch the textarea that seems to be the source of the sizing glitch.

    If I am annoying you with all my posts we can switch to email πŸ™‚

  9. About the settings reset, I was poking around in syntax_hilite.php and I think the problem has to be with igSynHilite_Install(), as all the values that reset are all the ones that are set to ‘true’ in the $igSHOptionsArr array. So somewhere in there its not respecting if the options have been changed to false. I can poke around more, but being familiar with the code you would probably have more success

    yeah you are right about that. I’ll look into it later today when I get some free time. πŸ˜‰

    As for Javascript issue, well, the createElement() etc. is not gonna help here. And that textarea disappearing, well, that seems to be a style dependent thing as well. If you see here on my test blog, there’s a single line codebox at the bottom & if you view it as plain text, it displays alright, doesn’t collapse like it does on your blog!! πŸ˜‰ Still I’ll see what can be done in this as well. πŸ™‚

    If I am annoying you with all my posts we can switch to email

    No, you are not annoying. Discussing here will also be of help to any others & I’ll also be able to refer back later(I usually delete all emails except some important ones). πŸ™‚

  10. what do you mean by that Jamie?

    PS: remember, you can’t post any code here, it’ll be stripped out, so better show it in a text file hosted on your server!! πŸ™‚

  11. it seems to adjust my code a bit. for example if i type in
    img src=”” it would show up as
    img xsrc=””
    is there a way to turn the xhtml formatting off? thank you very much πŸ™‚

  12. Jamie, as I’ve said repeatedly, your code isn’t modified by iG:Syntax Hiliter, so whether you write “src” or “xsrc” it doesn’t matter to the plugin!! And I don’t understand how come that’s happening, since I’ve never come across “xsrc” for “img” tag. You can however try turning off WordPress’ xHTML formatting by going to the Writing Options(in wp-admin) and unchecking the “WordPress should correct invalidly nested XHTML automatically” checkbox.

  13. Thank you so much for your advice. I wonder if it could be something with my server. Since when I checked into the option you specified, it was already off. I will do some more checking and let you know if I find something. Thank you for your help so far. I love the look of this program and will get it working with my install πŸ˜€

  14. Found a bug. If you don’t have WordPress installed in the same directory as your blog, then the JS and stuff doesn’t work.

    This is the correct code to be using:

    $igsyntax_hiliter_path = get_settings(‘siteurl’).”/wp-content/plugins/ig_syntax_hilite”;

  15. oh damn, I thought I had that fixed!! πŸ™ ok, thanks for pointing out, I was preparing for an update anyway, so its been fixed & will be available soon!! πŸ™‚

  16. Pingback: The Code Cave
  17. Hey,

    Quoting:

    “You will see that the syntax highlighter is inserting an end paragraph tag where this is no one open. Again, this problem only appears when Ò€œShow Line NumbersÒ€ is set to false.”

    Well, no this ahppens even with show line numbers on.

    However, luckly its a simple fix. πŸ˜‰

    Simply after [ /code ] add a blank line then two breaks, that is then another blank line. Problem solved. πŸ™‚

    Perhaps the plugin can auotmaticly do that?

    Take Care,

    Will

Sliding Sidebar