There should be an easy way to include some source code in the TWiki editor without reformatting the contents. I know there is the Attach button, but I want to document some lines of code or some shell commands in a HowTo list.

The <pre> ... </pre> is good, but you have to check for special characters, like <, > and $ because of HTML and RCS interpretation.

Example for RCS conflict

 <pre> # $Id$ </pre> 

which shows up as

 # $Id: ...some RCS infos... $ 

Example for HTML conflict

 <pre>	vi <testfile </pre> 

shows up as:

	vi 

A good solution would be to have a

 <verbatim>	vi <testfile </verbatim> 

which still shows up

	vi <testfile 

-- StefanScherer - 05 Jan 2001

Ok, I've found the function extendGetRenderedVersionInsidePRE(), but it enters with <PRE> at the beginning, so it is not really inside PRE.

But with this function, it is simple to something like this:

 s/\</&lt;/go; s/\>/&gt;/go; 

-- StefanScherer - 05 Jan 2001

My team would like to use Twiki to document our XML interfaces, which of course is all tags. We would love to have a verbatim mode for XML. Our need is fairly urgent. Has anyone implemented this yet?

-- WilliamHertling - 31 Jan 2001

Implemented and commited to TWikiAlphaRelease.

Syntax is

 <verbatim>	vi <testfile> </verbatim> 

Note that this does not solve the RCS issue since the keyword gets expanded at topic save time. In the rare cases where you do neet the un-escaped RCS keyword, write &#36;Id&#36; to get $Id$.

-- PeterThoeny - 31 Jan 2001

Thanks! I've tried it with a small code example from a TWiki template file. Is it possible to also work around the TWiki environment variables, like %EDITBOXHEIGHT%, because they are still active in verbatim mode?

I've tried to add the following to the current wiki.pm

 s/\%/&#37;/go; 

but it seems to be too late for such variables. Anyway, the current state of verbatim also helps a lot.

-- StefanScherer - 01 Feb 2001

No, it isnot possible to escape variable with the <verbatim> tag because of timing. Variables are evaluated first, then the rendering happens in a different function. You can escape variables with <nop> if needed, i.e. %<nop>EDITBOXHEIGHT%

-- PeterThoeny - 04 Feb 2001

That's ok, but: In <pre> mode, %<nop>EDITBOXHEIGHT% produces %EDITBOXHEIGHT%, but in <verbatim> mode, you still get %<nop>EDITBOXHEIGHT%.

For showing perl sourcecode, <verbatim> mode helps a lot, look at the second line of the following code:

 open FILE, "<input.txt"; $line = <FILE>; close FILE; 

This is a live demo of the <verbatim> mode.

-- StefanScherer - 05 Feb 2001

How about Wiki-izing the syntax? Perhaps use "" instead of <verbatim> with a second set of "" to turn it off?

Yes, I am a lazy typist. smile

-- BillCarlson - 27 Mar 2001

See also:

-- HansDonner - 26 Aug 2001

I noted the RCS expansion problem above. I've set TWiki to turn these off for binary attachments, we couldn't turn it off for all topics - thoughts?

-- JohnTalintyre - 28 Aug 2001

TopicClassification:
FeatureEnhancementRequest
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2001-08-28 - JohnTalintyre
 
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.