#line 1415 "/home/travis/build/felix-lang/felix/src/packages/flx_web.fdoc"
  
  var FLX_PKGCONFIG_PATH = Empty[string];
  var INSTALL_ROOT = "";
  var C_PATH = Empty[string];
  var FLX_PATH = Empty[string];
  
  fun get_file (var fname:string, path:list[string]) = {
    if fname.[0] == char "$" do fname = fname.[1 to]; done
    if FileStat::fileexists fname do return Some fname;
    else
      var f = Filename::join(INSTALL_ROOT,fname);
      if FileStat::fileexists f do return Some f;
      else return FileSystem::find_in_path (fname, path);
      done
    done
  }
  
  
  
  module Fpc2Html
  {
  fun xlat_fpc(t:string, dir:string) : bool * string =
  {
  println$ "formatting fpc data";
    var out = "";
    val lines = split(t,"\n");
    iter handle_line lines;
    return false, out;
  
    proc handle_line(s:string) {
      match split(s,":") with
      | Cons(fn,Cons(fv,Empty))  =>
        {
          out+= "<span class=fpc_fieldname>"+fn+": </span>";
          if fn in ("Requires","flx_requires_driver") do
            var pkgs=split$ fv.strip, " ";
            iter handle_pkg pkgs;
            out+="\n";
          elif fn == "includes" do
            var includes=split$ fv.strip, " ";
            iter handle_include includes;
            out+="\n";
          else out+= fv+"\n";
          done;
        }
      | x => { out+=s + "\n"; }
      endmatch;
    }
    proc handle_pkg(s:string) {
      match get_file(s+".fpc",FLX_PKGCONFIG_PATH) with
      | Some path => { out += '<a href="/$' + path + '">' + s + '</a> '; }
      | #None => { out += s + " "; }
      endmatch;
    }
    proc handle_include(s:string) {
      var n = s;
      while n.[0] in (char '"', char '<', char "'") do n=n.[1 to]; done
      while n.[-1] in (char '"',char '>',char "'") do n=n.[to -1]; done
      match get_file(n,C_PATH) with
      | Some path => { out += '<a href="/$' + path + '">' + s + '</a> '; }
      | #None => { out += s + " "; }
      endmatch;
    }
  }
  }
  
  eprintln$ Version::felix_version+"Fpc2html initialisation";
  
  fun setup(config_data:string) = {
    var config_lines = split(config_data, "\n");
    config_lines = map (strip of (string)) config_lines;
    var pathext = RE2("(.*)\\+=(.*)");
    var varset = RE2("(.*)=(.*)");
    var plugin_spec = RE2 " *extension (.*)->(.*)::(.*)";
  
    var result = varray[StringPiece] (4.size,StringPiece(""));
    for line in config_lines do
      var match_result = Match(pathext, StringPiece(line),0,ANCHOR_BOTH, result.stl_begin,3);
      if match_result do
        var lhs = result.1.str.strip;
        var rhs = result.2.str.strip;
        match lhs with
        | "FLX_PATH" => FLX_PATH += rhs;
        | "C_PATH" => C_PATH += rhs;
        | "FLX_PKGCONFIG_PATH" => FLX_PKGCONFIG_PATH += rhs;
        | _ => ;
        endmatch;
      else
      match_result = Match(varset, StringPiece(line),0,ANCHOR_BOTH, result.stl_begin,3);
      if match_result do
        lhs = result.1.str.strip;
        rhs = result.2.str.strip;
        match lhs with
        | "INSTALL_ROOT" => INSTALL_ROOT = rhs;
        | _ => ;
        endmatch;
      done done
    done
    return 0;
  }
  
  
  export fun setup of (string) as "fpc2html_setup";
  export fun Fpc2Html::xlat_fpc of (string * string) as "fpc2html";