[Home]WikiPatches/NoWiki

UseModWiki | WikiPatches | RecentChanges | Preferences

This "patch" simplifies the no-wiki plain text inclusion into the wiki pages. Line-break-insensitive text can be surrounded with <ntt> and </ntt>. Preformatted (line-break-sensitive) text can be surrounded by lines starting with angle brackets:

<<
Preformatted WikiFree text.
>>

Three and four angle brackets will yield some extra indentation.

Add the following to the EarlyRules configuration option in /etc/usemod-wiki/config:

$EarlyRules .= <<'EOER';
  $text =~ s#^\&lt;\&lt;\&lt;\&lt;(.*?)^\&gt;\&gt;\&gt;\&gt;#"<pre style=\"margin-left: 1in;\">" . &StoreRaw($1) . "</pre>"#ismge;
  $text =~ s#^\&lt;\&lt;\&lt;(.*?)^\&gt;\&gt;\&gt;#"<pre style=\"margin-left: 0.5in;\">" . &StoreRaw($1) . "</pre>"#ismge;
  $text =~ s#^\&lt;\&lt;(.*?)^\&gt;\&gt;#"<pre>" . &StoreRaw($1) . "</pre>"#ismge;
  $text =~ s#\&lt;npre(.*?)\&gt;(.*?)\&lt;/npre\&gt;#"<pre$1>" . &StoreRaw($2) . "</pre>"#ismge;
  $text =~ s#\&lt;ntt(.*?)\&gt;(.*?)\&lt;/ntt\&gt;#"<tt$1>" . &StoreRaw($2) . "</tt>"#ismge;
EOER

(Cut and paste the version produced by the engine rather than the original editable content).

To highlight code insets, enable the style sheet in /etc/usemod-wiki/config:

$StyleSheet  = "/usemod-wiki/wiki.css";

and then add the following line to /var/www/usemod-wiki/wiki.css:

PRE {
  background-color: #CCFFFF;
  overflow: auto;
  white-space: pre-wrap;
  white-space: -moz-pre-wrap !important;
}

The white-space property may be removed to enable horizontal scroll bars instead of wrapping long lines.


One still has to adjust the pre-formatted text if its line ends with a backslash character "\" because the backslash'es semantics as a line joiner isn't overriden by the patch. Replacing trailing backslashes with "&#92;" helps:

<<
Preformatted text ending with a backslash still needs special treatment in order to not get joined with the next line: &#92;
Suggestions on fixing this are welcome.
>>

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited November 6, 2007 11:53 pm by MarkusLude (diff)
Search: