                
<?php
//-->-->-->-->-->-->-->-->
//-- Description:
//--   The purpose of this function is to perform some standard
//--   transformations on a plain text string in order to render
//--   the text as meaningful HTML. For example filenames in the
//--   text are recognised and made into a 'teletype' font using
//--   the 'tt' HTML tag. This function complements the function
//--   fnHtmlCommonTransforms which should be called before the 
//--   current function.
//--
//--   Also the function fnHyperlinkPlainText should be called 
//--   before the current function (if at all). This order of calling
//--   the functions represents the importance of the plain text
//--   structures for rendering into HTML. For example, it is
//--   more important that file name type structures which appear
//--   in the context of hyperlinkable text should be hyperlinked
//--   rather than made into teletype type of text. This 
//--   order of calling functions is necessary because the plain
//--   text string allows fairly 'free-form' structures which may
//--   be in a sense ambiguous as to the way in which they should
//--   be rendered into HTML or into another more determinate
//--   format, such as XML
//--  
//-- Notes:
//--
//-- History:
//--
//-- Dependencies:
//-- See Also:
//--
//--
//-- Author:
//--   matth3wbishop@yahoo.com
//--   http://www.geocities.com/matth3wbishop/
//--

//include_once "fnHtmlCommonTransforms.php";

function fnHtmlCommonTransformsMore($sPlainText)
{
  $sReturn = $sPlainText;

  $sReturn = fnHtmlCommonTransforms($sReturn);

  //-- Make the title into a first level heading  
  $sReturn = 
    preg_replace("#^[ ]*=(.*)#m", "<center><h1>$1</h1></center><dl>", $sReturn);

  $sHeadings = $sReturn;

  $sHeadings = 
     preg_replace("#^[ \t]*#m", "", $sHeadings);

  $sHeadings = 
     preg_replace('#^[^\*].*$#im', '', $sHeadings);

  $sHeadings = 
     preg_replace("#\n\s*\n#m", "\n", $sHeadings);

  //-- Get rid of the leading 'star' characters for each of the questions
  $sHeadings = 
     preg_replace("#^\s*\*\s*#m", "", $sHeadings);

  $sHeadings = 
     preg_replace("#\s*$#m", "", $sHeadings);

  if ($sHeadings != "")
  {
    $sHeadings = 
      preg_replace("#^(.*)$#m", "<li><a href = '#$1'>$1</a>" , $sHeadings);

    $sHeadings = 
      "<a name = 'toc'></a><br><ol type = '1'>".$sHeadings."</ol>";
  }
  //echo "<pre>[$sHeadings]</pre>";
  //echo $sHeadings;
  $sReturn = preg_replace(
      "#^\s*\*\s*([^\n\r]*)#m", 
      "<dt><h4><a name = '$1'>$1</a>&nbsp;<a href = '#toc'>[toc]</a></h4></dt><dd>", 
      $sReturn);

  $sReturn = $sHeadings."\n".$sReturn;

  $sReturn = fnHyperlinkPlainText($sReturn);


  //-- Make a tab into 2 HTML spaces
  $sReturn = preg_replace("#\t#im", "&nbsp;&nbsp;", $sReturn);


  //-- get rid of the [*faq*] meta-tag which is used to tell the transformation
  //-- system that the current document should be transformed according to the 
  //-- rules for a journal for an faq style document.

  //-- This </dl> rubbish is a terrible hack. It is assuming that 
  //-- the faq flag occurs right at the end of the document and that
  //-- there is some kind of definition list in the doc. Very ugly.
  $sReturn = preg_replace("#^\s*\[\*faq\*\]\s*$#im", "</dl>", $sReturn);

  $sReturn = 
    preg_replace(
         "#<pre>((.|\n)*?)</pre>#ime", 
         "'<pre>'.fnCodeBlockFromHtml('$1').'</pre>'", $sReturn);

  return $sReturn;
} //-- function fnDocumentToHtml 
     

//--<--<--<--<--<--<--<--<
?>
                                                                                                                                                                                                                                                                                                    