Color Plugin

Informazioni generali

Questo plugin consente di formattare il testo specificato come se fosse la console di linux.

Sito: http://www.dokuwiki.org/plugin:cli

This plugins brings a Command Line Interface formatter to DokuWiki allowing you to format the output of a transcript say for a user manual or on-line tutorial. It is designed to work with the output of a standard Unix Bash Shell, but should be suitable to document other kinds of CLI interaction, e.g. Windows Command Window, Python and Ruby, Matlab, etc.

The assumptions made are

  1. all user commands start with a prompt
  2. the CLI prompt will end in a recognizable character (typically '$' or '>')
  3. user commands will follow the CLI prompt on the same line
  4. lines that do not start with a prompt are outputs from the CLI1)

A key design feature is that it should be possible to display a CLI transcript (e.g. output from a history file or copy of text from a console window) for display with the mimumum of additional markup.

It is possible to adjust the style of the display using a style sheet. For details refer to style.css.

Acknowledgements

A similar feature is to be found in MoinMoin Wiki and TiddlyWiki. The styles are based on those developed for the UNIX Tutorial for Beginners by Michael Stonebank. The plugin and its documentation are based on lessons learned from the Plugin Tutorial and Christopher Smith's implementation and documentation of the boxes plugin.

Several improvements suggested by Stephane Chazelas and Andy Webber.

Syntax

A simple Bash Shell interaction:

  <cli>
  user@host:~/somedir $ ls # List current directory
  conf      lang         README        screen.gif  ui
  info.txt  manager.dat  renderer.php  syntax.php
  user@host:~/somedir $ 
  </cli>

Should be rendered:

  <pre class="cli">
  <span class="cli_prompt">user@host:~/somedir $</span> <span class="cli_command">ls</span> <span class="cli_comment"># List current directory</span>
  <span class="cli_output">conf      lang         README        screen.gif  ui</span>
  <span class="cli_output">info.txt  manager.dat  renderer.php  syntax.php</span>
  <span class="cli_prompt">user@host:~/somedir $</span>
  </pre>

The full syntax:

  <cli prompt='prompt ' comment='comment'>
  transcript
  </cli>
  • prompt — [optional] the prompt used by the CLI. 2) If no prompt is given, '$ ' (note the space) is assumed 3).
  • comment — [optional] the comment string used by the CLI. If omitted, '#' is assumed 4).
  • continue – [optional] the prompt used for continuation markers: regex '/^> /' is the default.
  • The defaults above match Bourne shell ${PS1} and ${PS2} prompts and comments

The opening <cli … > must all appear on one line. The transcript contents can appear over as many lines as are needed.

Esempi

Code

  <cli>
  user@host:~/somedir $ ls # List current directory
  conf      lang         README        screen.gif  ui
  info.txt  manager.dat  renderer.php  syntax.php
  user@host:~/somedir $ 
  </cli>


<cli prompt="$">
$ rpm -ivh darcs-1.0.9-3.fc6.i386.rpm
Preparing...                ########################################### [100%]
   1:darcs                  ########################################### [100%]
</cli>

Result

user@host:~/somedir $ ls # List current directory
conf      lang         README        screen.gif  ui
info.txt  manager.dat  renderer.php  syntax.php
user@host:~/somedir $ 


$ rpm -ivh darcs-1.0.9-3.fc6.i386.rpm
Preparing...                ########################################### [100%]
   1:darcs                  ########################################### [100%]


1)
this turns out to be a problem for the Ruby interactive shell irb which seems to prefix every line with a prompt!
2)
In practice only the final character is needed as everything on the line up to the final character will be taken to be part of the prompt and everything after will be regarded as a command.
3)
'$ ' is the standard Bash shell prompt
4)
'#' is the standard Bash shell comment character
dokuwiki/plugins/cli.txt · Ultima modifica: 2015/06/08 20:15 da 127.0.0.1
Torna su
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0