<commit_before>// =================================================================
// Logtalk - Object oriented extension to Prolog
// Release 2.19.2
//
// Copyright (c) 1998-2004 <NAME>.  All Rights Reserved.
// =================================================================

var WshShell = new ActiveXObject("WScript.Shell");

var WshProcessEnv = WshShell.Environment("PROCESS");
var WshSystemEnv = WshShell.Environment("SYSTEM");
var WshUserEnv = WshShell.Environment("USER");
var logtalk_home;

if (WshProcessEnv.Item("LOGTALKHOME"))
	logtalk_home = WshProcessEnv.Item("LOGTALKHOME");
else if (WshSystemEnv.Item("LOGTALKHOME"))
	logtalk_home = WshSystemEnv.Item("LOGTALKHOME");
else if (WshUserEnv.Item("LOGTALKHOME"))
	logtalk_home = WshUserEnv.Item("LOGTALKHOME")
else {
	WScript.Echo("The environment variable LOGTALKHOME must be defined first!");
	usage_help();
	WScript.Quit(1);
}

var html_xslt = logtalk_home + "\\xml\\lgthtml.xsl";
var xhtml_xslt = logtalk_home + "\\xml\\lgtxhtml.xsl";
var xslt;

var format = "xhtml";
// var format = "html";

var directory = WshShell.CurrentDirectory;

var index_file = "index.html";
var title = "Entity documentation index";

var processor = "xsltproc";
// var processor = "xalan";
// var processor = "sabcmd";

if (WScript.Arguments.Unnamed.Length > 0)
	usage_help();

if (WScript.Arguments.Named.Exists("f"))
	format = WScript.Arguments.Named.Item("f");

if (WScript.Arguments.Named.Exists("d"))
	directory = WScript.Arguments.Named.Item("d");

if (WScript.Arguments.Named.Exists("i"))
	index_file = WScript.Arguments.Named.Item("i");

if (WScript.Arguments.Named.Exists("t"))
	title = WScript.Arguments.Named.Item("t");

if (WScript.Arguments.Named.Exists("p"))
	processor = WScript.Arguments.Named.Item("p");

if (format = "xhtml")
	xslt = xhtml_xslt;
else if (format = "html")
	xslt = html_xslt;
else {
	WScript.Echo("unsupported output format: " + format);
	usage_help;
	WScript.Quit(1);
}

if (processor != "xsltproc" && processor != "xalan" && processor != "sabcmd") {
	WScript.Echo("unsupported XSLT processor:" + processor);
	WScript.Echo("");
	WScript.Quit(1);
}

var fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFile(logtalk_home + "\\xml\\logtalk.dtd", WshShell.CurrentDirectory + "\\logtalk.dtd");
fso.CopyFile(logtalk_home + "\\xml\\logtalk.xsd", WshShell.CurrentDirectory + "\\logtalk.xsd");
fso.CopyFile(logtalk_home + "\\xml\\logtalk.css", directory + "\\logtalk.css");

WScript.Echo("");
WScript.Echo("converting XML files...");

var files = new Enumerator(fso.GetFolder(WshShell.CurrentDirectory).Files);

for (; !files.atEnd(); files.moveNext()) {
	var file = files.Item();
	if (fso.GetExtensionName(file) = "xml") {
		WScript.Echo("  converting" + fso.GetFileName(files.item()));
		var html_file = directory + "\\" + fso.GetBaseName(files.item()) + ".html";
		switch (processor) {
			case "xsltproc" :
				WshShell.Run(xsltproc + " -o " + html_file + xslt + " " + files.item(), true);
				break;
			case "xalan" :
				WshShell.Run(xalan + " -o " + html_file + " " + files.item() + " " + xslt, true);
				break;
			case "sabcmd" :
				WshShell.Run(sabcmd + " " + xslt + " " + files.item() + " " + html_file, true);
				break;
		}
	}
}

WScript.Echo("conversion done");
WScript.Echo("");
WScript.Echo("generating index file...");

index_file = directory + "\\" + index_file;

switch (format) {
	case "xhtml" :
		xhtml_index_file();
		break;
	case "html" :
		html_index_file();
		break;
}

WScript.Echo("index file generated");
WScript.Echo("");

fso.DeleteFile("logtalk.dtd");
fso.DeleteFile("logtalk.xsd");

WScript.Quit(0);

function usage_help() {<commit_msg>More bug fixes.<commit_after>// =================================================================
// Logtalk - Object oriented extension to Prolog
// Release 2.19.2
//
// Copyright (c) 1998-2004 <NAME>.  All Rights Reserved.
// =================================================================

var WshShell = new ActiveXObject("WScript.Shell");

var WshProcessEnv = WshShell.Environment("PROCESS");
var WshSystemEnv = WshShell.Environment("SYSTEM");
var WshUserEnv = WshShell.Environment("USER");
var logtalk_home;

if (WshProcessEnv.Item("LOGTALKHOME"))
	logtalk_home = WshProcessEnv.Item("LOGTALKHOME");
else if (WshSystemEnv.Item("LOGTALKHOME"))
	logtalk_home = WshSystemEnv.Item("LOGTALKHOME");
else if (WshUserEnv.Item("LOGTALKHOME"))
	logtalk_home = WshUserEnv.Item("LOGTALKHOME")
else {
	WScript.Echo("The environment variable LOGTALKHOME must be defined first!");
	usage_help();
	WScript.Quit(1);
}

var html_xslt = logtalk_home + "\\xml\\lgthtml.xsl";
var xhtml_xslt = logtalk_home + "\\xml\\lgtxhtml.xsl";
var xslt;

var format = "xhtml";
// var format = "html";

var directory = WshShell.CurrentDirectory;

var index_file = "index.html";
var title = "Entity documentation index";

var processor = "xsltproc";
// var processor = "xalan";
// var processor = "sabcmd";

if (WScript.Arguments.Unnamed.Length > 0)
	usage_help();

if (WScript.Arguments.Named.Exists("f"))
	format = WScript.Arguments.Named.Item("f");

if (WScript.Arguments.Named.Exists("d"))
	directory = WScript.Arguments.Named.Item("d");

if (WScript.Arguments.Named.Exists("i"))
	index_file = WScript.Arguments.Named.Item("i");

if (WScript.Arguments.Named.Exists("t"))
	title = WScript.Arguments.Named.Item("t");

if (WScript.Arguments.Named.Exists("p"))
	processor = WScript.Arguments.Named.Item("p");

if (format = "xhtml")
	xslt = xhtml_xslt;
else if (format = "html")
	xslt = html_xslt;
else {
	WScript.Echo("unsupported output format: " + format);
	usage_help;
	WScript.Quit(1);
}

if (processor != "xsltproc" && processor != "xalan" && processor != "sabcmd") {
	WScript.Echo("unsupported XSLT processor:" + processor);
	WScript.Echo("");
	WScript.Quit(1);
}

var fso = new ActiveXObject("Scripting.FileSystemObject");

fso.CopyFile(logtalk_home + "\\xml\\logtalk.dtd", WshShell.CurrentDirectory + "\\logtalk.dtd");
fso.CopyFile(logtalk_home + "\\xml\\logtalk.xsd", WshShell.CurrentDirectory + "\\logtalk.xsd");
fso.CopyFile(logtalk_home + "\\xml\\logtalk.css", directory + "\\logtalk.css");

WScript.Echo("");
WScript.Echo("converting XML files...");

var files = new Enumerator(fso.GetFolder(WshShell.CurrentDirectory).Files);

for (; !files.atEnd(); files.moveNext()) {
	var file = files.item();
	if (fso.GetExtensionName(file) = "xml") {
		WScript.Echo("  converting" + fso.GetFileName(file));
		var html_file = directory + "\\" + fso.GetBaseName(file) + ".html";
		switch (processor) {
			case "xsltproc" :
				WshShell.Run(xsltproc + " -o " + html_file + xslt + " " + file, true);
				break;
			case "xalan" :
				WshShell.Run(xalan + " -o " + html_file + " " + file + " " + xslt, true);
				break;
			case "sabcmd" :
				WshShell.Run(sabcmd + " " + xslt + " " + file + " " + html_file, true);
				break;
		}
	}
}

WScript.Echo("conversion done");
WScript.Echo("");
WScript.Echo("generating index file...");

index_file = directory + "\\" + index_file;

switch (format) {
	case "xhtml" :
		xhtml_index_file();
		break;
	case "html" :
		html_index_file();
		break;
}

WScript.Echo("index file generated");
WScript.Echo("");

fso.DeleteFile("logtalk.dtd");
fso.DeleteFile("logtalk.xsd");

WScript.Quit(0);

function usage_help() {
{'fraction_non_alphanumeric': 0.20990371389270976, 'fraction_numerical': 0.004676753782668501, 'mean_word_length': 4.793625498007968, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '457551', 'n_tokens_mistral': 2744, 'n_tokens_neox': 2574, 'n_words': 490}