Tags:
create new tag
view all tags

Question

Is there some plugin that can be used to create framed block of text (for Unix commands) having some color. Right now I use <verbatim> but this prefer frames of the same size to have a consistent output.

Environment

TWiki version:  
TWiki plugins:  
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- TonTLam - 08 Aug 2005

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

Have you tried BeautifierPlugin yet?

-- FranzJosefSilli - 08 Aug 2005

Do you mean something like this? (Look at the raw test to see how its done.


This is the body of the verbatim block.

Cool code goes here ....

You can of course do that by defining a "macro" in TWikiPreferences much the same way that LynnwoodBrown does in TopicClassificationAddOn with STARTSIDEBAR/STOPSIDEBAR (See TopicClassificationAddOnDev)

-- AntonAylward - 08 Aug 2005

I think Ton wants to define a style in one place and have that style apply everywhere the VERBATIM tag is used. I know Cairo can't do this without a custom code modification but I suspect that the upcoming DakarRelease could.

Ton - grep for 'verbatim' in the code and where its implemented surround the tag replacement with a blockquote construct like the one above. You could put the style part of the construct into a TWikiPreferences variable so you can change it without changing the code.

If you implement it, please post your change here so that others can see it.

-- MartinCleaver - 09 Aug 2005

Thanks a lot for all hints. Once you know it is simple. Set a preference (see the raw text)

  • Enable blocked text
    • Set STARTBLOCK =
            * Set STOPBLOCK = 

and from here use these words:

Test

Indeed I could check for <verbatim> and create likewise a new command within TWiki. Something like <command>, and </command>. I have already created a module, and will add this over there the above. I'll update tomorrow.

-- TonTLam - 10 Aug 2005

Can't you just edit one of the CSS files for whatever template you're using and add custom classes that do what you want? Then enclose text in a div of that class.

-- ClaussStrauch - 10 Aug 2005

Or specify a CSS setting for <verbatim>? -- Ups, that won't work, cause <verbatim> is no HTML-tag, silly me. wink

-- FranzJosefSilli - 10 Aug 2005

Okay, this is how I finalized this. Create some module ownstuff.pm. Having an own module means you don't have to go through the code again of a future TWiki release.

sub commonTagsHandler
{

    TWiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;

    $_[0] =~ s/%MYID{(.*?)}%/&handleMYID($1)/ge;

    $_[0] =~ s/<cmd>/<blockquote style="background-color:#fff0ff; font-family:times-roman; border:2px solid %WEBBGCOLOR%;padding:0.5em;"><pre>/g;
    $_[0] =~ s/<\/cmd>/<\/pre><\/blockquote>/g;
}

Then

<cmd>
# date
# pwd
</cmd>
will result in
# date
# pwd

If you compare this with the above, you see that <verbatim> has been replaced by <pre>, because verbatim is not replaced by pre automatically. The MYID is something that I use to replace whatever ID with the desired URL. I find this easier then Interwikiplugin.

sub handleMYID
{
        my ( $lines ) = @_;
        $lines =~ s/([A-Z]{3}[a-z]{2}\d{5})/\[\[http:\/\/a.b.com\/abc\/cgi-bin\/formaction.sh?$1]\[$1\]\]/ and return ( $lines );
        # more stuff
}

and simply do %MYID{ABCde12345}%, and likewise I have other conditions.

Thanks for all your help.

-- TonTLam - 11 Aug 2005

You are welcome. Thanks for sharing your output.

On reflection insertion of a CSS DIV around the output stream of the verbatim tag, together with a CSS definition of that DIV in the templates would be a more generic solution.

Do we have a point-click way of escalating a support request into a feature enhancement?

-- MartinCleaver - 11 Aug 2005

the PseudoXmlPlugin does exactly this sort of transormation of user-defined <tags>...</tags>, although i've usually opted for the BeautifierPlugin in the past.

-- WillNorris - 12 Aug 2005

some test cases (i'm trying to use the pure-twiki technique in BuildingDakar)

cd $TWIKIDEV/$BRANCH/twikiplugins/TWikiInstallerContrib/lib/TWiki/Contrib/TWikiInstallerContrib/cpan ./install-cpan.pl -f -mirror=./MIRROR/MINICPAN -baselibdir=$TWIKIDEV/CPAN Number::Compare Text::Glob File::Slurp File::Find::Rule File::Slurp::Tree File::Spec::Functions Getopt::Long Pod::Parser LWP::UserAgent LWP::UserAgent::TWiki::TWikiGuest </dev/null export MakeFor=twiki.org cd $TWIKIDEV/$BRANCH/twikiplugins/TWikiInstallerContrib/lib/TWiki/Contrib/TWikiInstallerContrib =twiki.org-`bin/svnrev.pl` time make distro

-- WillNorris - 13 Aug 2005

Even easier is to have a css. Upload this in your TWiki Home, say mystyle.css

pre     {
  background: #eeeeee;
  border: 1px solid #888888;
  color: black;
  padding: 1em;
  white-space: pre;
}

Then set

   * My style
      * Set USERSTYLEURL = %PUBURL%/Main/TonTLam/mystyle.css

From then on <pre>, </pre> is nicely framed. You can also put this in TWiki's CSS to make this global.

-- TonTLam - 26 Aug 2005

Edit | Attach | Watch | Print version | History: r14 < r13 < r12 < r11 < r10 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r14 - 2005-08-26 - TonTLam
 
  • Learn about TWiki  
  • Download TWiki
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.