2using System.Net.Sockets;
32 public override string Name =>
"html";
36 public override object?
Parse(
string[] args)
38 if (args.Length == 1 && args[0] !=
"--help" && args[0] !=
"help")
49 return base.Parse(args);
55 BadRuntimeSettings.Instance.CatchRuntimeExceptions =
false;
56 BadRuntimeSettings.Instance.WriteStackTraceInRuntimeErrors =
true;
61 Runtime.UseScriptDebugger();
70 Runtime.UseConsole(host);
81 if (!
string.IsNullOrEmpty(settings.
Model))
86 foreach (
string file
in settings.Files)
88 string outFile = Path.ChangeExtension(file,
"html");
91 int originalSize = htmlString.Length;
95 htmlString = htmlString.Replace(
"\n",
" ")
99 while (htmlString.Contains(
" "))
101 htmlString = htmlString.Replace(
" ",
" ");
106 "Minified output to {1} characters({0}%)",
107 Math.Round(htmlString.Length / (
float)originalSize * 100, 2),
122 return Task.FromResult(0);
Implements a Html Template.
static BadHtmlTemplate Create(string file, IFileSystem? fileSystem=null)
Creates a new Template.
string Run(object? model=null, BadHtmlTemplateOptions? options=null, BadScope? caller=null)
Runs the Template with the specified arguments.
Options for the Html Template Engine.
Exposes the BadScript Runtime Functionality to Consumers.
Wrapper class for the console abstraction.
static void WriteLine(string str)
Writes a string to the console and appends a newline.
Implements a Host for the Remote Console.
void Start()
Starts the Host.
Implements a Console System that uses a settings object of Type T.
Runs the Html Template Engine.
override? object Parse(string[] args)
override Task< int > Run(BadHtmlSystemSettings settings)
BadHtmlSystem(BadRuntime runtime)
Creates a new BadHtmlSystem instance.
Settings for the Html Template Engine System.
bool Debug
If Enabled, the Debugger will be attached to the process.
string Model
The Model that the templates will use.
int RemotePort
If Specified the Remote Console will be started on the specified port.
bool SkipEmptyTextNodes
Indicates if empty HTML Text nodes should be skipped.
Public interface for the filesystem abstraction of the BadScript Engine.
static void WriteAllText(string path, string contents)
Wrapper for IFileSystem.OpenWrite that creates the file if it does not exist.
Implements a Json to BadObject Converter.
static BadObject FromJson(string s)
Converts a Json string to a BadObject.
The Base Class for all BadScript Objects.
A Html Template Generator based on BadScript2.
Contains the Implementation of the Remote Console Abstraction over TCP.
Contains a Console Abstraction Layer to be able to Simulate Console Input/Output over the Network.
Contains the 'html' console command implementation.
Contains the debugger implementations for the BadScript2 Runtime.
Contains IO Implementation for the BadScript2 Runtime.
Contains JSON Extensions and APIs for the BadScript2 Runtime.
Contains the Runtime Objects.
Contains Runtime Settings Objects.