@
/* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2002 Cédric Lemaire
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
To contact the author: codeworker@free.fr
*/
function LaTeX2HTML(sLaTeX : value) {
local myHTMLDoc;
insert myHTMLDoc.sParsingMode = "description";
createVirtualFile(".#f1", sLaTeX);
createVirtualFile(".#f2", "");
try {
translate("LaTeX2HTML.cwp", myHTMLDoc, ".#f1", ".#f2");
} catch(sError) {
traceLine("error in the piece of LaTeX:");
traceLine(sLaTeX);
error(sError);
}
local sResult = loadVirtualFile(".#f2");
deleteVirtualFile(".#f2");
deleteVirtualFile(".#f1");
return sResult;
}
function HTMLAnchor(sLabel) {
set sLabel = replaceString("#", "_", sLabel);
set sLabel = replaceString("&", "_", sLabel);
set sLabel = replaceString(";", "_", sLabel);
set sLabel = replaceString(" ", "_", sLabel);
set sLabel = replaceString("%", "_", sLabel);
set sLabel = replaceString("@", "_", sLabel);
set sLabel = replaceString("=", "_", sLabel);
set sLabel = replaceString("<", "_", sLabel);
set sLabel = replaceString(">", "_", sLabel);
set sLabel = replaceString("\"", "_", sLabel);
set sLabel = replaceString("'", "_", sLabel);
set sLabel = replaceString("/", "_", sLabel);
set sLabel = replaceString("-", "_", sLabel);
set sLabel = replaceString("+", "_", sLabel);
set sLabel = replaceString(".", "_", sLabel);
return sLabel;
}
function fileDescription(sFilename : value) {
local myFile;
parseAsBNF("fileDescription.cwp", myFile, sFilename);
local sResult;
if myFile.description set sResult = LaTeX2HTML(myFile.description);
if existVariable(myFile.input) {
set sResult += endl() + "" + endl() + "Input files:";
set sResult += endl();
foreach i in myFile.input {
if !first(i) set sResult += ", ";
set sResult += "" + i + "";
}
set sResult += "." + endl();
}
if existVariable(myFile.file) {
set sResult += endl() + "
" + endl() + "quoted files:";
set sResult += endl();
foreach i in myFile.file {
if !first(i) set sResult += ", ";
set sResult += "" + i + "";
}
set sResult += "." + endl();
}
if existVariable(myFile.output) {
set sResult += endl() + "" + endl() + "output files:";
set sResult += endl();
foreach i in myFile.output {
if !first(i) set sResult += ", ";
set sResult += "" + i + "";
}
set sResult += "." + endl();
}
return sResult;
}
if getMarkupKey() == "today" {
@@formatDate(getNow(), "%B %d, %Y")@
@
} else if getMarkupKey() == "aujourd'hui" {
local frenchMonths;
insert frenchMonths["jan"] = "janvier";
insert frenchMonths["feb"] = "février";
insert frenchMonths["mar"] = "mars";
insert frenchMonths["apr"] = "avril";
insert frenchMonths["may"] = "mai";
insert frenchMonths["jun"] = "juin";
insert frenchMonths["jul"] = "juillet";
insert frenchMonths["aug"] = "août";
insert frenchMonths["sep"] = "septembre";
insert frenchMonths["oct"] = "octobre";
insert frenchMonths["nov"] = "novembre";
insert frenchMonths["dec"] = "décembre";
@@formatDate(getNow(), "%d")@ @frenchMonths[formatDate(getNow(), "%b")]@ @formatDate(getNow(), "%Y")@
@
} else if getMarkupKey() == "version" {
@@getVersion()@
@
} else if startString(getMarkupKey(), "size:") {
local iSize = fileSize(getWorkingPath() + "WebSite/" + subString(getMarkupKey(), 5));
@ (@floor($iSize / 1024$)@kb)@
} else if getMarkupKey() == "repository-content" {
@
@
foreach i in this.theme {
local sHTML = LaTeX2HTML(i);
@ - @sHTML@
@
}
@
@
} else if getMarkupKey() == "repository" {
local listOfFileAnchors;
foreach i in this.theme {
local sHTMLTheme = LaTeX2HTML(i);
@
@sHTMLTheme@ |
@LaTeX2HTML(i.description)@ |
@
foreach j in i.subject {
local sHTMLSubject = LaTeX2HTML(j);
local sSubjectAnchor = HTMLAnchor(sHTMLTheme + '_' + sHTMLSubject);
@
@j.state@ |
@sHTMLSubject@ |
@LaTeX2HTML(j.description)@ |
@
if existVariable(j.script) {
@
|
Script |
Description |
@
foreach k in j.script {
local sFileAnchor = "repository_" + HTMLAnchor(k);
local sScriptLink;
if k.rightString(4) in {".cws", ".cwt", ".cwp"} {
local theHTMLTranslation;
insert theHTMLTranslation.docURL = "../";
set sScriptLink = "highlighting/" + replaceString(k.rightString(4), ".html", k);
translate("WebSite/repository/CWscript2HTML.cwp", theHTMLTranslation, "WebSite/repository/" + k, "WebSite/" + sScriptLink);
} else {
set sScriptLink = "repository/" + k;
}
@
|
@k@ |
@
if k.link || findElement(sFileAnchor, listOfFileAnchors) {
@see @LaTeX2HTML(i + "::" + j)@@
} else {
insert listOfFileAnchors[sFileAnchor] = sFileAnchor;
@
@fileDescription("WebSite/repository/" + k)@@
}
@
|
@
}
}
if existVariable(j.file) {
@
|
File |
Description |
@
foreach k in j.file {
local sScriptLink;
if k.rightString(4) in {".cws", ".cwt", ".cwp"} {
local theHTMLTranslation;
insert theHTMLTranslation.docURL = "../";
set sScriptLink = "highlighting/" + k.rsubString(4) + ".html";
translate("WebSite/repository/CWscript2HTML.cwp", theHTMLTranslation, "WebSite/repository/" + k, "WebSite/" + sScriptLink);
} else {
set sScriptLink = "repository/" + k;
}
@
|
@k@ |
@fileDescription("WebSite/repository/" + k)@ |
@
}
}
if existVariable(j.example) {
@
|
Example |
Description |
@
foreach k in j.example {
local sScriptLink;
if k.rightString(4) in {".cws", ".cwt", ".cwp"} {
local theHTMLTranslation;
insert theHTMLTranslation.docURL = "../";
set sScriptLink = "highlighting/" + k.rsubString(4) + ".html";
translate("WebSite/repository/CWscript2HTML.cwp", theHTMLTranslation, "WebSite/examples/" + k, "WebSite/" + sScriptLink);
} else {
set sScriptLink = "examples/" + k;
}
@
|
@k@ |
@fileDescription("WebSite/examples/" + k)@@
try {
traceLine("executing example '" + k + "' of the repository...");
local sOldIncludePath = getIncludePath();
setIncludePath("WebSite/");
local sOldWorkingPath = getWorkingPath();
setWorkingPath("WebSite/");
setCommentBegin("//");
setCommentEnd("\n");
executeString(this, loadFile("examples/" + k));
setCommentBegin("");
setWorkingPath(sOldWorkingPath);
setIncludePath(sOldIncludePath);
} catch(sError) {
error("on Web site, example '" + k + "':" + endl() + sError);
}
@ |
@
}
}
@
|
@
}
@
@
}
} else if getMarkupKey() == "repository-working" {
foreach i in this.working {
local sHTMLVersion = LaTeX2HTML(i);
@
@sHTMLVersion@ |
State |
Description |
@
switch(i.state) {
case "progress":
@in progress@
break;
case "pending":
case "complete":
@@i.state@@
break;
}
@ |
@LaTeX2HTML(i.description)@ |
@
}
} else if startString(getMarkupKey(), "quick access:") {
local sMode = subString(getMarkupKey(), 14);
foreach i in project.headings if i.modes.findElement(sMode) {
@ @repeatString(" ", 8)@Category @key(i)@
@
}
@
@
foreach i in project.headings if i.modes.findElement(sMode) {
@
Category @key(i)@ |
@LaTeX2HTML(i.description)@ |
@
foreach j in sorted i.members if !j.mode || j.mode == sMode {
@
@j.name@ |
@LaTeX2HTML(j.abstract)@ |
@
}
@
@
}
}