TextArea

<< | Cookbook-V1 | >>

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

Provide a =textarea markup to allow scrolling display of program listings.

Solution

Add the following to local.php:

    $InlineReplacements['/^=textarea (.*)$/'] =
      '<textarea cols="60" rows="6" wrap="no">$1</textarea>';

Discussion

The above code adds =textarea markup; any text following =textarea is displayed in an HTML <textarea> control box with scrollbars. This can be useful for placing long sections program source code or other "verbatim" things in a page. For example, the markup

 
=textarea [=
<?php
    print "Here is some sample PHP code\n";
    print "Complete with variables and other items\n";
?>
=]

produces

=textarea <?php print "Here is some sample PHP code\n"; print "Complete with variables and other items\n"; ?>

A useful feature of this approach is that many browsers make it easy to select the contents of a textarea control (for copy-and-paste operations) by using CTRL-A or some other keyboard shortcut.

See Also

  • PmWiki.CustomMarkup

Contributors

  • <#>?, based on a suggestion from Patrick Ogay

pmwiki-2.3.34 -- Last modified by {{}}?

from IP: 85.171.160.186 ip should be disabled by default for security reasons