Highlighted forum codeblocks
BlitzMax Forums/BlitzMax Programming/Highlighted forum codeblocks
| ||
I dont know if this is the right topic to post this, but here goes: I was tired of looking at boring source code on this forum so i whipped up a simple highlighter for greasemonkey (an extension for firefox) to fix that for me :D i really wish this was done server side, with options for c/c++ etc, but i digress. Latest version (0.8) adds line numbering, see the image below. Example: ![]() You can install the script from here: http://userscripts.org/scripts/show/26817 |
| ||
Nice, thanks for the script. |
| ||
noel cower, genius, and all grown up, what are you working on these days? |
| ||
Depends on the street corner. |
| ||
ahaha, no chance of an imposter here! |
| ||
Awesome! I kind of like it how it is, not built-in, makes it customizable and doesn't add to the server latency. |
| ||
nice :) I was wondering about code highlighting server side not that long ago. I still think it would be a better way (for security reasons mainly). I don't know how secure greasemonkey is though. |
| ||
Thanks, i have updated the script since i last posted as well. Fixing some bugs and adding highlighting for codeboxes namely. I don't know how secure greasemonkey is though. Since scripts run at the domain level, they have access to cookies/history etc from the originating site. So someone could potentially get access to your account. But cross-site scripting isnt possible as far as i know, so running trusted scripts wont endanger you or your other sites. But you should always check the script to see what it does anyways ;) |
| ||
But you should always check the script to see what it does anyways ;) Yep, I did that :) |
| ||
not to derail the thread (looks like a cool utility) but here is a great set of regular expressions to accomplish the same... http://www.phoboslab.org/log/2007/08/generic-syntax-highlighting-with-regular-expressions would be easy to modify for blitz, at least it was pretty easy to modify for Lua (and php4) here was my result... http://www.physle.com/lua/ |
| ||
I just modified this code, added a link at the bottom of the newly created code blocks that allows you to select the code. |
| ||
I just modified this code, added a link at the bottom of the newly created code blocks that allows you to select the code. Thanks for sharing :D Ive updated the script at userscript.org with your changes, hope you dont mind. |
| ||
Nice addition! There is a problem when highlighting Rem/End Rem blocks (the script only handles Rem/EndRem): Rem a block comment End Rem Function Uhoh(snap!) End Function Print "~n" Actually, it seems like its not even highlighting Rem/EndRem blocks anymore.. |
| ||
it seems like its not even highlighting Rem/EndRem blocksanymore.. Thanks for letting me know, its fixed now =) |
| ||
I've noticed a (slightly) handy side effect of my code addition, if someone has split code into multiple boxes, you can just click [Select Above Code] for each one and it will continue to add to the selection, so you can copy it all at once instead of back and forthing. hope you dont mind. Not at all. |
| ||
This option works great, it makes this forum soooo better readable!!! Thanks a whole lot :-) |
| ||
I just saw this :D |
| ||
If anyone's interested, I've just made this: http://www.blitzbasic.com/Community/posts.php?topic=78196 (adds forum codes buttons and modifies the post textarea) |
| ||
The "don't format comment if in a string" part isn't working either, see here (fredborg's code, you don't even have to scroll down, its the first Print call): http://www.blitzbasic.com/Community/posts.php?topic=50045&hl=dll EDIT: The whole code in his post doesn't format correctly, when the comment in string thing gets fixed be sure to check it again, there could be something else buggerd up. EDIT2: [Select Above Code] doesn't work on his post either. |
| ||
[Select Above Code] doesn't work on his post either. my fault (I think) |
| ||
The "don't format comment if in a string" part isn't working That was my fault, for copying Perturbatios code verbatim off the forum ;) It should be fixed now. The other error i cant seem to reproduce... Oh and im also using Perturbatios forum helper script (thanks!) |
| ||
It should be fixed now. The other error i cant seem to reproduce... It only occurs when you have my script running after yours, changing the order in greasemonkey seems to solve it. |
| ||
It only occurs when you have my script running after yours, changing the order in greasemonkey seems to solve it. Works for me too! |
| ||
I think I know what's causing it. I think it's a result of my script using innerHTML instead of transferring the DOM nodes, rewriting innerHTML doesn't re-attach the eventListeners. I'll try changing my code to shift the nodes instead. (I knew innerHTML was going to come back and bite me, I don't normally use it when writing code at work). |
| ||
fixed this now (I hope), seems to work for me regardless of the script order. |
| ||
Ive updated the script with Line Numbering if anyone is interested. Check the image in the top post as to how it looks. |
| ||
Great! Thank you very much! |
| ||
Yup, thanks :) |