-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
2,606 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
backup | ||
dependencies | ||
lib | ||
out | ||
htmlresemb.exe | ||
htmlresemb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# HTML Resource Embedder | ||
|
||
HTML Resource Embedder (`htmlresemb`) tries to embed all external resources like CSS, JavaScript and | ||
image files into an HTML document. It reads the content of those files and modifies the corresponding | ||
tags (`link`, `style` and `img`) accordingly. CSS and JavaScript files are embedded into a CDATA | ||
section, so in most cases there shouldn't be a problem with characters like `>` in the resource files. | ||
Image files will be converted to a Base64 encoded data URI. | ||
|
||
The resulting document is in most cases "portable", that is, it can be copied/moved to other locations | ||
without breaking the layout. Please note that currently embedding of font files isn't supported. This | ||
may be added in the future but can be a license problem depending on the font. | ||
|
||
## Usage | ||
|
||
```bash | ||
htmlresemb -i <infile> -o <outfile> [options] | ||
``` | ||
|
||
- `<infile>`\ | ||
Use <infile> for input. If `-i <infile>` is ommitted, input is read from stdin. In this case a | ||
document root path must be supplied via `-docroot`, otherwise loading of resources referenced in | ||
the document is impossible. | ||
|
||
- `<outfile>`\ | ||
Use `<outfile>` for output. If `-o <outfile>` is ommitted, output goes to stdout. | ||
|
||
**Available options (others are silently ignored):** | ||
|
||
- `-h, --help`\ | ||
Print help message and exit. | ||
|
||
- `-docroot <path>`\ | ||
A path which is used to resolve relative filenames. Relative paths and environment variables can be | ||
used in `path`. | ||
|
||
- `-css`\ | ||
Embed CSS files. | ||
|
||
- `-js`\ | ||
Embed JavaScript files. | ||
|
||
- `-img`\ | ||
Embed image files. | ||
|
||
|
||
If none of the switches `-css`, `-js` and `-img` is used, *all* resources will be embedded. | ||
|
||
**Return values:** | ||
|
||
- **0**  Success. | ||
- **1**  Invalid/incomplete options or `-h` / `--help` was used. | ||
- **2**  An error occured. | ||
|
||
Warning or error messages during processing are written to stderr. | ||
|
||
|
||
## Status | ||
|
||
`htmlresemb` is by no means a perfect solution, it's a very quick spin off from one of our other | ||
internal projects. In general it does it's best and should just work, but it hasn't been tested with | ||
many different documents. For example encodings other than UTF-8 will fail (mostly). Reading of the | ||
source document is done with an XML parser, so this also may fail completely (although `htmlresemb` | ||
tries to fix broken HTML to some extent). Also the output document might contain slightly different | ||
whitespace. | ||
|
||
|
||
## Development | ||
|
||
`htmlresemb` is written in Free Pascal, the Mac and Windows binaries (see [Releases](../../releases/)) | ||
were created with compiler version 2.6.4 and Lazarus 1.4.4. You also need the `LazUtils` package | ||
(part of FPC) and [Internet Tools](https://github.com/benibela/internettools). The Internet Tools | ||
version used for `htmlresemb` is available as a Zip file in the [Releases](../../releases/) section. | ||
|
||
The source code contains a slightly modified | ||
version of `xmlwriter.pas` to overcome indenting and whitespace problems when creating the result | ||
document. If you want to use a newer compiler version this maybe no longer necessary, but it's very | ||
likely that you have to change larger parts of the source code due to the new Unicode string | ||
handling in FPC 3.x. The Lazarus project file depends on `strip` as a post compile command, on the Mac | ||
this should be available if the Apple developer tools are installed, on Windows using Cygwin/MinGW is | ||
one possible solution. | ||
|
||
|
||
## Credits | ||
|
||
- [Free Pascal](https://www.freepascal.org) | ||
- [Lazarus](https://www.lazarus-ide.org) | ||
- [Benito van der Zander](http://www.benibela.de) (Internet Tools) | ||
|
||
## License | ||
|
||
MIT © [idesis GmbH](http://www.idesis.de), Rellinghauser Straße 334F, D-45136 Essen | ||
|
||
See the `LICENSE` file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<ProjectOptions> | ||
<Version Value="9"/> | ||
<General> | ||
<Flags> | ||
<MainUnitHasCreateFormStatements Value="False"/> | ||
<MainUnitHasTitleStatement Value="False"/> | ||
</Flags> | ||
<SessionStorage Value="InProjectDir"/> | ||
<MainUnit Value="0"/> | ||
<Title Value="htmlresemb"/> | ||
<UseAppBundle Value="False"/> | ||
<ResourceType Value="res"/> | ||
</General> | ||
<i18n> | ||
<EnableI18N LFM="False"/> | ||
</i18n> | ||
<VersionInfo> | ||
<UseVersionInfo Value="True"/> | ||
<AutoIncrementBuild Value="True"/> | ||
<MinorVersionNr Value="9"/> | ||
<BuildNr Value="10"/> | ||
<StringTable CompanyName="idesis GmbH" FileDescription="Embed external resources into HTML files" InternalName="idesis HTML Resource Embedder" LegalCopyright="@2018 idesis GmbH" OriginalFilename="htmlresemb" ProductName="HTML Resource Embedder" ProductVersion="0.9"/> | ||
</VersionInfo> | ||
<BuildModes Count="2"> | ||
<Item1 Name="Mac" Default="True"/> | ||
<Item2 Name="Windows"> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<Target> | ||
<Filename Value="htmlresemb"/> | ||
</Target> | ||
<SearchPaths> | ||
<IncludeFiles Value="$(ProjOutDir)"/> | ||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
</SearchPaths> | ||
<CodeGeneration> | ||
<Optimizations> | ||
<OptimizationLevel Value="3"/> | ||
</Optimizations> | ||
</CodeGeneration> | ||
<Linking> | ||
<Debugging> | ||
<GenerateDebugInfo Value="False"/> | ||
</Debugging> | ||
</Linking> | ||
<Other> | ||
<ExecuteAfter> | ||
<Command Value="strip.exe $(ProjPath)htmlresemb.exe"/> | ||
</ExecuteAfter> | ||
</Other> | ||
</CompilerOptions> | ||
</Item2> | ||
</BuildModes> | ||
<PublishOptions> | ||
<Version Value="2"/> | ||
</PublishOptions> | ||
<RunParams> | ||
<local> | ||
<FormatVersion Value="1"/> | ||
</local> | ||
</RunParams> | ||
<RequiredPackages Count="2"> | ||
<Item1> | ||
<PackageName Value="LazUtils"/> | ||
</Item1> | ||
<Item2> | ||
<PackageName Value="internettools"/> | ||
</Item2> | ||
</RequiredPackages> | ||
<Units Count="6"> | ||
<Unit0> | ||
<Filename Value="htmlresemb.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit0> | ||
<Unit1> | ||
<Filename Value="uHTMLResEmb.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit1> | ||
<Unit2> | ||
<Filename Value="uOptions.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit2> | ||
<Unit3> | ||
<Filename Value="uUtil.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit3> | ||
<Unit4> | ||
<Filename Value="uXMLWriter.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit4> | ||
<Unit5> | ||
<Filename Value="uMain.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit5> | ||
</Units> | ||
</ProjectOptions> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<Target> | ||
<Filename Value="htmlresemb"/> | ||
</Target> | ||
<SearchPaths> | ||
<IncludeFiles Value="$(ProjOutDir)"/> | ||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
</SearchPaths> | ||
<CodeGeneration> | ||
<Optimizations> | ||
<OptimizationLevel Value="3"/> | ||
</Optimizations> | ||
</CodeGeneration> | ||
<Linking> | ||
<Debugging> | ||
<GenerateDebugInfo Value="False"/> | ||
</Debugging> | ||
</Linking> | ||
<Other> | ||
<ExecuteAfter> | ||
<Command Value="strip $(ProjPath)htmlresemb"/> | ||
</ExecuteAfter> | ||
</Other> | ||
</CompilerOptions> | ||
<Debugging> | ||
<Exceptions Count="3"> | ||
<Item1> | ||
<Name Value="EAbort"/> | ||
</Item1> | ||
<Item2> | ||
<Name Value="ECodetoolError"/> | ||
</Item2> | ||
<Item3> | ||
<Name Value="EFOpenError"/> | ||
</Item3> | ||
</Exceptions> | ||
</Debugging> | ||
</CONFIG> |
Oops, something went wrong.