Tags:
create new tag
view all tags

SID-00297: Code highlighting and command line text

Status: Answered Answered TWiki version: 4.3.1 Perl version: 5.8.6
Category: CategoryEditing Server OS: Fedora Core 4, Kernel 2.6.11 Last update: 12 years ago

Hi all,

We document unix scripts on our twiki site. As of now, I use <verbatim> to display command output or part of shell script. But I would love to have a tag like <console> or <code-highlight> to display what I need. <console> would have a black background and white or green text, like in a terminal window. <code-highligth> would highlight shell script syntax the way vim does.

Do you know if there is something already existing to do that ? Any tips from your own experience ?

Thanks a lot.

-- JeromeBoismartel - 2009-05-05

Discussion and Answer

There are several plugins with the Extensions:syntax_highlighting tag. I haven't tried them so I have no tips/experience to offer.

-- SeanCMorgan - 2009-05-05

You can also define your own preference settings to define a new style. Example setting in your TWiki.TWikiPreferences:

   * Set STARTCONSOLE = <verbatim style="color: #33DD33; background: black; padding: 5px">
   * Set ENDCONSOLE = </verbatim>

Then you can use it anywhere:

/var/www/twiki/bin
[paul@intra bin]$ pwd
/var/www/twiki/bin
[paul@intra bin]$ ls
attach   LocalLib.cfg      logon   mystuff  rdiff      rename       save        statistics  viewauth
changes  LocalLib.cfg.txt  logos   oops     rdiffauth  resetpasswd  search      upload      viewfile
edit     login             manage  preview  register   rest         setlib.cfg  view

(Do a "Raw view" to see how this works.)

-- PeterThoeny - 2009-05-05

Nice one, Peter. I was trying to do that, but couldn't get it to work right.

P.S. I changed it to use the brighter 'lawngreen' instead of 'green',

because I find this 'green' too hard to read
smile

-- SeanCMorgan - 2009-05-05

Yes, that green was a bit dull on the black background. However, the lawngreen looked kind of biting on my screen. I changed it to #33DD33.

-- PeterThoeny - 2009-05-05

You could write a plugin to expand <console> ... </console> if you prefer that syntax over %STARTCONSOLE% ... %ENDCONSOLE%.

-- PeterThoeny - 2009-05-05

With this solution, is there a way to suppress variable expansion? Compare how these render:

%BR% %TOPIC%

<br />  SID-00297

P.S. don't try to edit this page with WYSIWYG!

-- SeanCMorgan - 2009-05-06

I don't think that's possible due to rendering eval sequence. You'd need to write a plugin.

-- PeterThoeny - 2009-05-06

Fair enough. In the meantime, it works if you don't use the preference variables:

Case 1: normal text
Case 2: HTML markup: <i>italic text</i> &copy;
Case 3: TWiki markup: %BR% %TOPIC% =test= *test* __test__ [[test][test]]

-- SeanCMorgan - 2009-05-06

That 's exactly what I was looking for ! This is great thanks a lot.

-- JeromeBoismartel - 2009-05-15

Yes Thank you all very much... Great solution !

-- Jerome Boismartel - 2013-12-18

      Change status to:
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.
SupportForm
Status Answered
Title Code highlighting and command line text
SupportCategory CategoryEditing
TWiki version 4.3.1
Server OS Fedora Core 4, Kernel 2.6.11
Web server apache
Perl version 5.8.6
Browser & version

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2013-12-18 - JeromeBoismartel
 
  • 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.