<?php


  // contents of function TranslateForumCode

/*

Copyright © 2001 Nick Gammon.

  This program is free software; you can redistribute it and/or modify 
  it under the terms of the GNU General Public License as published by 
  the Free Software Foundation; either version 2 of the License, 
  or (at your option) any later version. 

  This program is distributed in the hope that it will be useful, 
  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  See the GNU General Public License for more details. 

*/

  // first fixup \[,  \\ and \] by translating them into something that
  // hopefully won't appear in the message

  $message = str_replace ('\\\\', chr(1), $message);
  $message = str_replace ('\\[',  chr(2), $message);
  $message = str_replace ('\\]',  chr(3), $message);
  
  // bold
  $message = str_replace ('[b]', '<b>', $message);
  $message = str_replace ('[/b]', '</b>', $message);
  // italic
  $message = str_replace ('[i]', '<i>', $message);
  $message = str_replace ('[/i]', '</i>', $message);
  // underline
  $message = str_replace ('[u]', '<u>', $message);
  $message = str_replace ('[/u]', '</u>', $message);
  // quote
  $message = str_replace ('[quote]', '<ul><hr>', $message);
  $message = str_replace ('[/quote]', '<hr></ul>', $message);
  // code
  $message = str_replace ('[code]', '<pre><code><font size=2>', $message);
  $message = str_replace ('[/code]', '</font></code></pre><p></p>', $message);

  // mono
  $message = str_replace ('[mono]', '<code><font size=2>', $message);
  $message = str_replace ('[/mono]', '</font></code>', $message);
   
  // line
  $message = str_replace ('[hr]', '<hr>', $message);

  // space
  $message = str_replace ('[sp]', '&nbsp;', $message);
  
  // lists
  
  $message = str_replace ('[ul]', '<ul>', $message);
  $message = str_replace ('[/ul]', '</ul>', $message);
  $message = str_replace ('[ol]', '<ol>', $message);
  $message = str_replace ('[/ol]', '</ol>', $message);
  $message = str_replace ('[li]', '<li>', $message);
  
  // put back  [,  \ and ] (without the backslash)

  $message = str_replace (chr(1), '\\', $message);
  $message = str_replace (chr(2), '[',  $message);
  $message = str_replace (chr(3), ']',  $message);
?>
