Tags:
create new tag
, view all tags

How Do I Wrap Text in verbatim Tags?

* Problem: I make liberal use of verbatim tags in my documentation. I use them to include blocks of linux shell command lines and output. However, it is quite annoying that the verbatim blocks don't automatically wrap text when rendered.

* Question: Is there a way to globally or locally configure Twiki so that verbatim blocks are text-wrapped? Is there some other type of blocking I should use?

* Example:

  1. prepare a typical procedure to demonstrate the problem
  2. create a numbered step
    1. prepare a very long command line
      [aaron@server]$ echo -n "Here is a"; for (( a=1; a<50; a++ )); do echo -n "very, "; done; echo "long line."
      Here is avery, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, long line.
      
      • Note how the line extends far beyond the edge of the screen, and is difficult to read.
    2. make a MANUALLY wrapped command line to demonstrate what I WANT it to look like:
      [aaron@server]$ echo -n "Here is a"; for (( a=1; a<50; a++ )); do echo -n
      "very, "; done; echo "long line that I manually wrapped."
      Here is avery, very, very, very, very, very, very, very, very, very, very, very,
      very, very, very, very, very, very, very, very, very, very, very, very, very, very,
      very, very, very, very, very, very, very, very, very, very, very, very, very, very,
      very, very, very, very, very, very, very, very, very long line that I manually
      wrapped.
      
      • Note how much nicer that looks. It would be nice if Twiki could do that automatically.

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: linux
Web server: Apache
Perl version: 5.8.5
Client OS: Win XP
Web Browser: Firefox 2.0.0.9
Categories: Missing functionality

-- AaronCutchin - 28 Nov 2007

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

You need to change the CSS Stylesheet property of the html pre tag. Normally it is set to no-wrap, but you can change it to normal.

For example:

<style>
pre#test {white-space: normal;}
</style>

< verbatim id="test">
[aaron@server]$ echo -n "Here is a"; for (( a=1; a<50; a++ )); do echo -n "very, "; done; echo "long line."
Here is avery, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, long line.
< /verbatim>

Will render as:

[aaron@server]$ echo -n "Here is a"; for (( a=1; a<50; a++ )); do echo -n "very, "; done; echo "long line."
Here is avery, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, long line.

The example above is a per-case basis using an id (#test). For global settings use

<style>
pre {white-space: normal;}
</style>

You can write this in an overriding stylesheet. How to do this is explained in PatternSkinCssCookbook.

-- ArthurClemens - 28 Nov 2007

Anyway, as a shell programmer you should consider using \ to break long lines.

-- MarcoSilva - 29 Nov 2007

 
Change status to:
Topic revision: r3 - 2007-11-29 - MarcoSilva
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.