htmlc 1.0.156

dotnet tool install --global htmlc --version 1.0.156
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local htmlc --version 1.0.156
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=htmlc&version=1.0.156
nuke :add-package htmlc --version 1.0.156

htmlc - HTML Compiler

html-compiler-tool

.NET Version License Downloads NuGet

Lines of Code Vulnerabilities Coverage

buy me a coffe

This is the HTML Compiler Tool for your cli. htmlc is a small tool with which very easily static HTML files from various HTML components, including layout files and reusable HTML blocks (such as header, footer, etc.) from separate HTML files. The result is written to a complete and finished HTML file. Sass/SCSS compilation is also supported (the path to generated CSS file is then written into the HTML file). In the end you don't have to touch the generated html files.

content

installation and update

  1. install the .NET Runtime you need to install the .NET Runtime (its free and available for macos, linux and windows)
  1. install the tool then you can install the html-tool very simple via this command:
dotnet tool install --global htmlc

update htmlc

dotnet tool update --global htmlc

usage

The compile process searches in the folder for all HTML files. All files that do NOT start with an underscore are compiled. Files with an underscore (for example _layout.html or _footer.html) are used as reusable components.

commands

new-command

The new command creates a new project at the current folder location. The project contains the following elements:

  • .gitignore - the git ignore file
  • /src - the source directory for your files
    • /src/index.html - the html index file
    • /src/shared - the directory for alle shared components (like layout, etc.)
      • /src/shared/_layout.html - the layout file for all html files
  • /dist - the output directory
options

you can use the following options with the new command:

-d --docker - creates a simple Dockerfile with nginx configuration.

example: htmlc new -d

-t --template - creates a project based on the given template name. If several templates matching the search filter are found, a url can be specified (which must be available in one of the template repositories!)

example: htmlc new -t Demo

-v --vscode - add configuration directory for Visual Studio Code (.vscode) and settings-file.

example: htmlc new -v

-l --vsliveserver - add configuration for Visual Studio Code Extension Live Server (recommended) - * important:* vscode settings file needed. create via html flag -v --vscode needed!

example: htmlc new -l

the vsliveserver option creates the property liveServer.settings.root and sets it to the output directory in the vscode settings file

compile-command

This command compiles all HTML files from the /src (rekusriv) folder and writes the results to /dist.

htmlc compile <project-directory>

If only one path is specified, htmlc searches for /src and /dist in this directory. If these do not exist, then they are created. Then htmlc searches for files in /src and writes the results to the /dist directory. If no path is specified, then htmlc searches for /src and /dist in the current folder.

project-directory (optional): the path to the project directory. for example: /path/to/project

htmlc compile <source-directory> <output-directory>

If two folders are specified, then htmlc uses the first value as the source path and the second value as the output paths.

source-directory (optional): The path to the source directory (equivalent to /src). for example: /path/to/project/src

output-directory (optional): The path to the output directory (equivalent to /dist). for example: /path/to/another/directory/output

htmlc compile [...] [-s --style {path/to/main.scss}]

Optionally, a relative path to the style entry file can be specified with -s or -style. the path to the style file must be specified relative to the /src directory. the relative path to the final css-file is written to the @StylePath-tags.

watch-command

This command compiles all HTML files from the /src (rekusriv) folder and writes the results to /dist. then /src is observed for changes and recompiled whenever a change is made.

htmlc watch <project-directory>

The watch command is identical to the compile command. The only difference is that the watch command observes the directory after the first compile and restarts the compile process every time a change is made.

project-directory (optional): the path to the project directory. for example: /path/to/project

htmlc watch <source-directory> <output-directory>

If two folders are specified, then htmlc uses the first value as the source path and the second value as the output paths.

source-directory (optional): The path to the source directory (equivalent to /src). for example: /path/to/project/src

output-directory (optional): The path to the output directory (equivalent to /dist). for example: /path/to/another/directory/output

htmlc watch [...] [-s --style {/path/to/main.scss}]

Optionally, a relative path to the style entry file can be specified with -s or -style. the path to the style file must be specified relative to the /src directory. the relative path to the final css-file is written to the @StylePath-tags.

environment-commands

The environment commands are used to secure the htmlc environment (e.g. all required dependencies, etc.)

check-command

The command checks if certain dependencies are installed:

  • NodeJS
  • sass
  • less

The dependencies are registered in the code via dependency injection.

setup-command

This command executes necessary steps to install the dependencies.

template-commands

Via the template commands htmlc provides all necessary commands to manage templates.

create-command

Creates a template from an htmlc project which is ready to be distributed.

  • source-directory - the path to the source directory (equivalent to /repos/my-website).
  • output-directory (optional) - the path to the template archive. /htmlc-templates/my-website.zip. if no path is given then the template is created in the source directory.
htmlc template create {source-directory} [output-directory]

example: (creates a template at /repos/my-website/template.zip)

htmlc template create /repos/my-website

html files

different html types

entry html

The compiler searches for all HTML files which do NOT start with an underscore (index.html, a-page.html, etc.). files like _layout.html, footer.html, etc. are ignored.

for example:

/src/index.html<br /> /src/pages.html<br /> /src/components/buttons.html<br />

layout

The layout file must start with an underscore. The rest of the naming is up to you. the content consists of reusable layout in HTML (styles and scripts, header, navigation, etc.).

for example:

/src/_layout.html<br />

reusable components

In addition, you can use other recyclable components. The file name must start with an underscore. The rest of the naming is up to you.

for example:

/src/_navigation.html<br /> /src/_header.html<br /> /src/_footer.html<br />

supported tags and its functionality

The @PageTitle-Tag

The value of PageTitle is set as a global variable. Each time @PageTitle is used, this location is replaced with the value.

The @Layout-Tag

The @Layout tag is used in an HTML entry file to specify which layout file is to use.

The @Body-Tag

The @Body tag determines in a layout file where the content from the actual HTML entry file is written.

The @File-Tag

You can include another file with the @File tag in any HTML file (whether layout file. reusable file or entry file).

The @MarkdownFile-Tag

You can include markdown code from files with the @MarkdownFile tag in any HTML file (whether layout file. reusable file or entry file). The Markdown code will be rendered in HTML.

The @StylePath-Tag

htmlc can also compile style files (scss or sass). the path of the compiled CSS file can be inserted using this * @StylePath* tag. The following usage makes sense:<br />

<link rel="stylesheet" href="@StylePath">
The @Comment-Tag

Creates an HTML comment:

@Comment=Example-Text
`
The @Global-Tag

htmlc supports Global Variables. These are loaded from a JSON file. By default, the global.json file in the root directory of the project is configured for this (Which file to load can be configured in the .htmlc file).

You can load all JSON entries via the @Global tag and thus write them to the HTML.

global.json (Global Variables File)

{
    "Application": {
        "Name": "title of website"
    }
}

index.html (Sample HTML File)

<div>
    <h1>@Global:Application:Name</h1>
</div>

result

<div>
    <h1>title of website</h1>
</div>
The @StartHtmlSpecialChars and @EndHtmlSpecialChars-Tag

You can escape special characters in a section HTML. To do this, place the following tags @StartHtmlSpecialChars and @EndHtmlSpecialChars before and after the block to be escaped:

@StartHtmlSpecialChars
<h1>a h1 heading</h1>
@EndHtmlSpecialChars

turns into

&#60;h1&#62;a h1 heading&#60;/h1&#62;
The @Var-Tag

htmlc supports the use of variables. JSON is always used as content. All @Var entries are merged by htmlc into a JSON object. This means that two equal @Var calls are always overwritten by the last entry.

set a variable

NOCTICE: a htmlc variable must always contain JSON!

The following code is used to set a variable. htmlc merges all variables into a single JSON object. An htmlc variable must stand alone in a line, so there must be nothing before or after it.

@Var={"Title":"Hello World!"}

@Var={"Data":{"Persons":[,{"Name":"Lisa Mustermann","Username":"lmustermann"},{"Name":"Fred Conrad","Username":"fconrad"}]}}

access a variable

A call to read a variable is simple. It starts with @Var and always ends with a semicolon ";". In between the path inside the JSON object is specified. Individual levels are separated by a colon ":". Access to entries in an array are done with an index access (The numbering always starts at 0!). For example, one accesses the 4 record with [3].

To access a variable, use this call:

<p>@Var["Data:Persons:[1]:Name"];</p>

result:

<p>Fred Conrad</p>

The @VarFile-Tag

The @VarFile tag works the same way as the @Var tag. A file name is specified behind it. This file is called in the project and the content is loaded. This file must contain JSON. The content is then processed as with the @Var content and added to the global variable JSON object. The access to the variable is done via @Var

getting started with your own project

  1. create a directory with two subdirectories /src and /dist. All project files must be stored under /src. The compiler writes the results under /dist.
  2. create an initial entry file index.html.
  3. create a layout file _layout.html.
  4. write the following basic HTML structure in the _layout.html file.
<html>
    <head>
    </head>
    <body>
        @Body
    </body>
</html>
  1. write the following example in index.html.
@Layout=_layout.html
<section>
    <div>Hello again</div>
</section>
  1. open the console of your choice and change to the project directory. (/src and /dist must be in it).
  2. type the following command:
htmlc compile
  1. under /dist should now appear a file index.html with the following content:
<html>
    <head>
    </head>
    <body>
        <section>
            <div>Hello again</div>
        </section>
     </body>
</html>
The @BuildDate-Tag

The BuildDate is used to provide the date of execution. Optionally, a string can be specified for formatting.

The DateTime logic of .NET (https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) is used.

example:

htmlc build date: @BuildDate (Depending on the language setting of the executing system)
CopyRight @BuildDate("yyyy") - My Website
Format Date @BuildDate("yyyy-MM-dd")

result:

htmlc build date: 10/09/2023 23:10:25 (Depending on the language setting of the executing system)
CopyRight 2023 - My Website
Format Date 2023-10-09
The @ImageString-Tag

The ImageString tag can be used to protect sensitive information from bots and similar tools (does not guarantee 100% protection). The transferred text is returned as a simple base64 PNG graphic string, which can be displayed in HTML.

example:

<p><img src="@ImageString("This is a secure string", "#ff0000", "#0000ff", 20)" /></p>

result:

<p><img src="data:image/png;base64, **************" /></p>
parameters:
  • text - the text to be displayed in the image
  • background (optional - default: white) - the background color of the image
  • foreground (optional - default: black) - the foreground color of the image
  • font-size (optional - default: 20px) - the size of the displayed text

licenses

Cocona (MIT)

console app environment

MIT License

Copyright (c) Mayuki Sawatari <mayuki@misuzilla.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

FluentDataBuilder (MIT)

for fluent data generation and json editing

MIT License

Copyright (c) 2023 Lars Krämer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

HtmlAgilityPack (MIT)

for html editing

The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Markdig (BSD-2-Clause)

for markdown rendering

Copyright (c) 2018-2019, Alexandre Mutel
All rights reserved.

Redistribution and use in source and binary forms, with or without modification
, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

NLog (BSD-3-Clause)

for logging

Copyright (c) 2004-2021 Jaroslaw Kowalski <jaak@jkowalski.net>, Kim Christensen, Julian Verdurmen

All rights reserved.

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions 
are met:

* Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer. 

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution. 

* Neither the name of Jaroslaw Kowalski nor the names of its 
  contributors may be used to endorse or promote products derived from this
  software without specific prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
THE POSSIBILITY OF SUCH DAMAGE.

SkiaSharp (MIT)

for image rendering

Copyright (c) 2015-2016 Xamarin, Inc.
Copyright (c) 2017-2018 Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.156 536 12/3/2023
1.0.155 194 11/8/2023
1.0.154 310 11/6/2023
1.0.153 245 11/6/2023
1.0.149 218 10/10/2023
1.0.148 179 10/9/2023
1.0.147 146 10/6/2023
1.0.146 145 10/6/2023
1.0.145 172 10/4/2023
1.0.144 229 9/28/2023
1.0.143 180 9/28/2023
1.0.142 178 9/27/2023
1.0.141 260 9/27/2023
1.0.140 163 9/27/2023
1.0.139 187 9/24/2023
1.0.137 176 9/23/2023
1.0.136 223 9/19/2023
1.0.135 157 9/19/2023
1.0.133 198 9/19/2023
1.0.132 250 9/19/2023
1.0.131 151 9/19/2023
1.0.128 224 9/17/2023
1.0.124 158 9/7/2023
1.0.121 226 9/6/2023
1.0.117 190 8/27/2023
1.0.115 605 8/11/2023
1.0.114 553 8/2/2023
1.0.112 409 7/29/2023
1.0.109 443 7/26/2023
1.0.107 393 7/26/2023
1.0.106 408 7/24/2023
1.0.72 732 2/17/2023
1.0.70 568 2/17/2023
1.0.69 712 2/17/2023
1.0.68 650 2/17/2023
1.0.66 660 2/17/2023
1.0.64 616 2/10/2023
1.0.63 708 1/23/2023
1.0.62 808 1/23/2023
1.0.61 792 1/23/2023
1.0.60 815 1/23/2023
1.0.59 665 1/23/2023
1.0.58 673 1/21/2023
1.0.57 706 1/21/2023
1.0.56 766 1/21/2023
1.0.55 622 1/21/2023
1.0.54 710 1/21/2023
1.0.53 609 1/21/2023
1.0.52 680 1/21/2023
1.0.51 766 1/6/2023
1.0.50 654 1/6/2023
1.0.49 790 1/5/2023
1.0.48 746 1/5/2023
1.0.47 789 1/5/2023
1.0.46 838 1/5/2023
1.0.45 798 1/5/2023
1.0.44 868 1/5/2023
1.0.43 877 1/4/2023
1.0.42 774 1/4/2023
1.0.41 865 1/4/2023
1.0.40 798 1/4/2023
1.0.39 819 1/4/2023
1.0.38 847 1/4/2023
1.0.37 780 1/4/2023
1.0.36 769 1/4/2023
1.0.35 762 1/3/2023
1.0.34 832 1/3/2023
1.0.33 862 1/3/2023
1.0.32 833 1/3/2023
1.0.31 734 1/2/2023
1.0.30 731 1/2/2023
1.0.29 729 1/2/2023
1.0.28 790 1/2/2023
1.0.27 839 1/1/2023
1.0.26 800 1/1/2023
1.0.25 753 1/1/2023
1.0.24 756 1/1/2023
1.0.23 691 1/1/2023
1.0.22 746 1/1/2023
1.0.21 692 1/1/2023
1.0.20 707 1/1/2023
1.0.19 316 12/31/2022
1.0.18 300 12/31/2022
1.0.17 319 12/31/2022
1.0.16 316 12/31/2022
1.0.15 292 12/29/2022
1.0.14 288 12/28/2022
1.0.13 309 12/28/2022
1.0.12 317 12/20/2022
1.0.11 392 11/4/2022
1.0.10 387 11/1/2022
1.0.9 370 11/1/2022
1.0.8 401 10/31/2022
1.0.6 387 8/21/2022
1.0.4 384 8/18/2022
1.0.3 393 8/17/2022
1.0.2 393 8/17/2022
1.0.0 389 8/17/2022