1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#############################################################################
##
#W files.gi GAP4 package `Utils' Sebastian Gutsche
## Max Horn
## Stefan Kohl
#Y Copyright (C) 2015-2025, The GAP Group,
#############################################################################
## this function has been transferred from RCWA
##
#F Log2HTML ( logfilename ) . . . . convert GAP logfile to XHTML 1.0 Strict
##
BindGlobal( "Log2HTML",
function ( logfilename )
local outputname, s1, s2, header, footer, pos,
lastlf, nextlf, crlf, prompt;
if ARCH_IS_UNIX() then crlf := 1; else crlf := 2; fi;
header := Concatenation(
"<?xml version = \"1.0\" encoding = \"ISO-8859-1\"?>\n\n",
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n",
" \"http://www.w3.org/TR/xhtml1/DTD/",
"xhtml1-strict.dtd\">\n<html>\n\n<head>\n <title> ",
logfilename, " </title>\n <link rel = \"stylesheet\" ",
"type = \"text/css\" href = \"gaplog.css\" />\n",
"</head>\n\n<body>\n\n<pre class = \"logfile\">\n");
footer := "</pre> </body> </html>";
s1 := StringFile( logfilename );
pos := PositionSublist( s1, "gap>" );
prompt := "gap> ";
s2 := ReplacedString( s1{[1..pos-1]}, "<", "<" );
while pos <> fail do
s2 := Concatenation(s2,"<em class = \"prompt\">",prompt,"</em>");
s2 := Concatenation(s2,"<em class = \"input\">");
nextlf := Position(s1,'\n',pos); prompt := "gap>";
if nextlf = fail then
nextlf := Length(s1);
fi;
s2 := Concatenation(s2,ReplacedString(s1{[pos+5..nextlf-crlf]},
"<","<"),"</em>");
while nextlf < Length(s1) and s1[nextlf+1] = '>' do
s2 := Concatenation(s2,"\n<em class = \"prompt\">></em>",
"<em class = \"input\">");
lastlf := nextlf;
nextlf := Position(s1,'\n',lastlf);
if nextlf = fail then
nextlf := Length(s1);
fi;
s2 := Concatenation(s2,ReplacedString(s1{[lastlf+2..nextlf-crlf]},
"<","<"),"</em>");
od;
s2 := Concatenation( s2, "\n" );
pos := PositionSublist( s1, "\ngap>", nextlf-1 );
if pos = fail then
pos := Length(s1);
fi;
if pos > nextlf then
s2 := Concatenation(s2,"<em class = \"output\">",
ReplacedString( s1{[nextlf+1..pos-crlf]},
"<", "<"), "</em>\n" );
fi;
if pos > Length(s1) - 3 then
break;
fi;
od;
s2 := Concatenation( header, s2, footer );
logfilename := LowercaseString( logfilename );
if ( PositionSublist(logfilename,".log") <> fail ) then
outputname := ReplacedString( logfilename, ".log", ".html" );
elif ( PositionSublist( logfilename, ".txt" ) <> fail ) then
outputname := ReplacedString( logfilename, ".txt", ".html" );
else
outputname := Concatenation( logfilename, ".html" );
fi;
FileString( outputname, s2 );
end );
#############################################################################
##
#E files.gi . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here
|