Author |
Topic |
Dan Martin
Average Member
USA
528 Posts |
Posted - 21 July 2002 : 03:41:46
|
I'm tinkering with changing the [code] tag. I really like how they show code here: http://www.dynamicdrive.com/dynamicindex5/linkinfo.htm
Their textarea is defined like this: <textarea rows="8" name="final2" cols="45" wrap="virtual" style="width:98%">
Which is cool, because it resizes. No more entire threads becoming 5 pages wide. Also it's much easier to copy and paste these.
I thought I could pull it off by changing the [code] tag handling in inc_functions. Well, it worked, except that you need to Server.HTMLEncode the data between the tags. Anyone have an idea how I could do that?
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 21 July 2002 : 06:32:22
|
Rather tha change the functionality of the forums [ code ] tag, you would be better making your own additional tag, that way you won't break anything in the forum while you are getting it to work.
what problem do you have with HTMLEncoding the message ?
|
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 21 July 2002 : 14:02:32
|
hey dan, kind of an interesting idea, but maybe use a DIV instead.
<div style="overflow:scroll;width:100%;height:100%;">
just a thought. it can be tweaked quite nicely too.
http://www.nineinchnailz.com |
|
|
Dan Martin
Average Member
USA
528 Posts |
Posted - 21 July 2002 : 19:46:28
|
quote: you would be better making your own additional tag, that way you won't break anything in the forum while you are getting it to work.
I thought of that. However, if you keep the old decode statement, change the encode statement, and add your own decode statement, everything works fine. If someone edits or quotes a message with a code chunk, it will decode back fine, but after the editing it will end up with the new format. I hope that makes sense, but I can give a better explanation if it doesn't.
quote: what problem do you have with HTMLEncoding the message ?
Well, actually I was mistaken. Currently the linefeeds are getting converted to <BR> tags, but then show up in the textarea as <BR> instead of linefeeds.
Dayve, I tried your suggestion. It works, and I prefer the way it looks. But it loses the benefit of easier "Select All". In fact, selecting the code can be difficult. I also still have the issue with the proper formatting.
If you want to see it, here's examples of both: http://danknows.com/forum/topic.asp?TOPIC_ID=7
My cable modem has been in and out all day. So if that link isn't working, I apologize.
|
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 21 July 2002 : 20:43:34
|
quote:
I thought of that. However, if you keep the old decode statement, change the encode statement, and add your own decode statement, everything works fine. If someone edits or quotes a message with a code chunk, it will decode back fine, but after the editing it will end up with the new format. I hope that makes sense, but I can give a better explanation if it doesn't.
That wasn't the reason I suggested it, but so that you can use both, if you are only posting 2 ior 3 short lines, why would you want a scrolling area.
|
|
|
Dan Martin
Average Member
USA
528 Posts |
Posted - 21 July 2002 : 21:01:39
|
Two reasons. 1) Code, no matter how many lines, in it's current form can force a thread to be wider than the page. This, as I'm sure you'll agree, can make a thread difficult to read 2) The current code chunks copy and paste badly. When I copy and paste them into a normal text editor, I end up with all the lines mashed into 1 line.
I personally am looking to change the old tag to get rid of these problems.
|
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 21 July 2002 : 21:19:35
|
When I write html pages that provide scripting tutorials, I put the code parts in a text box also if the intention will be that the person needs to copy and paste the code. However, if the intention is just to read the code to get, have to scroll makes it difficult to see the entire picture. You could maybe do different code options based on if the code is for viewing or for pasting. Or, as far as the scrolling goes, you could maybe only have it display the horizontal scrollbar if needed.
Nikkol |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 21 July 2002 : 21:30:32
|
About those <br> and <p> tags, can't you filter them out before displaying the code by using a replace function, like this:
Replace(This_Song.Fields.Item("LYRICS").Value, "<br>", vbcrlf) Replace(This_Song.Fields.Item("LYRICS").Value, "<p>", vbcrlf) Replace(This_Song.Fields.Item("LYRICS").Value, "</p>", vbcrlf)
This code is actually a modified part of my lyrics pages, but I'm sure you get the idea
Roland
http://www.frutzle.com
Snitz Exchange | Do's and Dont's |
|
|
Dan Martin
Average Member
USA
528 Posts |
Posted - 21 July 2002 : 23:06:29
|
I understand that. But how do I do it in docode() in inc_functions, for just the portion of the post between [ code ] and [/code] tags?
Edited by - Dan Martin on 21 July 2002 23:08:55 |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
|
Dan Martin
Average Member
USA
528 Posts |
Posted - 21 July 2002 : 23:29:31
|
Um....did Frutz just lose it before our eyes?
|
|
|
Deleted
deleted
4116 Posts |
|
Roland
Advanced Member
Netherlands
9335 Posts |
|
Deleted
deleted
4116 Posts |
Posted - 22 July 2002 : 00:37:19
|
Not tested, but one char + or - ... Just get the idea...
function doCode(fString, fOTag, fCTag, fROTag, fRCTag) DIM s fOTagPos = Instr(1, fString, fOTag, 1) fCTagPos = Instr(1, fString, fCTag, 1) while (fCTagPos > 0 and fOTagPos > 0) if f0tag = "[NEWCODE]" then s = mid(fString, fOTagPos + len(fOTag), fCTagPos - fOTagPos - len(fOTag)) s = replace(s,"<br>", vbCrLf) s = replace(s,"<p>" , vbCrLf) s = replace(s,"</p>", vbCrLf) ' so the following also strips out the tags fString = left(fString, f0TagPos-1) & s & mid(fString,fCTagPos + len(fCTag) + 1) fOTagPos = Instr(1, fString, fOTag, 1) fCTagPos = Instr(1, fString, fCTag, 1) else fString = replace(fString, fOTag, fROTag, 1, 1, 1) fString = replace(fString, fCTag, fRCTag, 1, 1, 1) fOTagPos = Instr(1, fString, fOTag, 1) fCTagPos = Instr(1, fString, fCTag, 1) end if wend doCode = fString end function
Think Pink ==> Start Internationalization Here
Edited by - bozden on 22 July 2002 00:40:18 |
|
|
Deleted
deleted
4116 Posts |
Posted - 22 July 2002 : 01:16:03
|
Well, it is much better to define a new function doNewCode(fString) and call it from chkString once. You will also add other starting/ending there (given above).
Think Pink ==> Start Internationalization Here |
|
|
James
Average Member
USA
539 Posts |
Posted - 22 July 2002 : 21:14:26
|
I like how it looks beter in the second example. Also, you might consider adding a header that lets the reader know that it's code above the text box.
Also, how well do you have this working if several people posts code in a thread, or if a user posted snippets of code with text between different parts (as we currently do with several code /code tags in a message). Just curious if it poses a problem or not.
- *Interested in Radio Control* *The RC Web Board - http://www.rcwebboard.com/* |
|
|
Topic |
|
|
|