EllenM1
May 15 2003, 06:06 AM
Hi, I want to be able to post blocks of code in articles, just like this:
CODE
<b>THIS IS SOME CODE</b>
How are people doing this in MoveableType?
crys
May 15 2003, 06:12 AM
At the moment I put the code in <pre> tags and the search & replace < -> < + > -> > -- I've got a text filter plug-in almost done that uses
CODE
[code] [b]
type tags though including translating the contents of [ code ] tags to display the code.
stepan
May 15 2003, 06:24 AM
Instead of search-and-replace, you can use
Quick Escape to escape HTML for you.
bmk
May 15 2003, 06:30 AM
I've been using brad's macro plugin for this:
CODE
<MTMacroDefine pattern="m/\[code\](.+?)\[\/code\]/si">
<pre><MTMacroMatch position="1" encode_html="1"></pre>
</MTMacroDefine>
Then surround your code with code tags:
CODE
[CODE]
CODE
[/CODE]
EllenM1
May 15 2003, 09:19 AM
Thanks for all the very helpful suggestions. So with these types of escaped characters, when someone copies and pastes the code, do they get the < and >symbols, or do they get all the escape codes that create them? I mean - can they use it, or do they pretty much have to go in and fix it all?
I know that when you use a text field to type code in, it can be copied and pasted just fine.
EllenM1
May 15 2003, 09:31 AM
Oh, I think I've got it: first run the code thru that accessify page, then just surround it with a < textarea > tag, and you're done?
gramcracker
May 15 2003, 09:35 AM
That's one way to do it, Ellen. And putting it in a textarea tag makes it easily selectable, too, which is nice.
morgantj
May 15 2003, 10:31 AM
Ah, I was trying to do this one time... I couldn't figure it out, so I ended up taking a screenshot! This is great, thank you.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.