                                                                                                                                                                                    


<?php
//-->-->-->-->-->-->-->-->
//--Description:
//--   The purpose of this function is to transform a string of text
//--   into HTML. The string of text is considered to be a 'list' of
//--   some sort. It is indicated by the '-' (dash) character at 
//--   the beginning of each list item and it is delimited by a line
//--   which is completely empty or contains only space characters.
//--   Its beginning is delimited by the text 'a-' or '1-' depending
//--   on the way that the list is suggested to be numbered in the 
//--   output.
//--
//--   I intend to make use of the 'callback' feature of the php regular
//--   expressions in order to achieve a similar effect to the sed line
//--   delimiter functionality. The trick I will use is to transform the
//--   text into something determinately unmatchable by all other regular
//--   expressions, and then at the end of all regular expressions, 
//--   untransform that same text, leaving it in its original state.
//--
//--
//--
//--See Also:
//--   http://wagga-cwc.org.au/refurb/product-data/lib/journal-to-html.sed
//--     This is an example of using the 'sed' program to do a similar task
//--
//--Author:
//--  matth3wbishop@yahoo.com
//--  http://www.geocities.com/matth3wbishop/
//--
//--History:
//--
//--


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

  //-- The characters *, =, - can have special meaning to the 
  //-- text transformation functions. So in this function we are putting
  //-- them 'out of harms way' when they occur between '<pre>' tags
  //-- which tags are designed to stop special formatting of any kind.
  //--

  $sReturn = 
   preg_replace(
         "#^\s*([a1I]-)((.|\n)*)#im", 
         "<ol>$1 $2</ol>\n\n", $sReturn);

  //-- if the first hyphen is doubled introduce a css style which
  //-- should prevent any marker from being used. 
  $sReturn = 
   preg_replace(
         "#^\s*([u]--)((.|\n)*)#im", 
         "<ul style = 'list-style: none;'>$1 $2</ul>\n\n", $sReturn);


  $sReturn = 
   preg_replace(
         "#^\s*([u]-)((.|\n)*)#im", 
         "<ul>$1 $2</ul>\n\n", $sReturn);

  $sReturn = preg_replace("#<ul>u--#im", "<ul>\n<li>", $sReturn);
  $sReturn = preg_replace("#<ul>u-#im", "<ul>\n<li>", $sReturn);
  $sReturn = preg_replace("#<ol>a-#im", "<ol type = 'a'>\n<li>", $sReturn);
  $sReturn = preg_replace("#<ol>1-#im", "<ol type = '1'>\n<li>", $sReturn);
  $sReturn = preg_replace("#<ol>I-#im", "<ol type = 'I'>\n<li>", $sReturn);
  $sReturn = preg_replace("#^\s*-#im", "<li>", $sReturn);


  return $sReturn;
} //-- function fnListBlockToHtml 
     
//--<--<--<--<--<--<--<--<
?>
                                                                                                                                                                                    