By William Jeffrey Rankin, Thu Dec 5 2024
Hua can be run at regular intervals using a scheduled task (on Windows) or a cron job (on Linux/Cygwin). On Windows, I use a simple batch script:
D:
cd Documents\Hua
D:\PowerShell-7.4.6-win-x64\pwsh .\hua.ps1 .\hua.cfg
Then I create a scheduled task. Two examples are shown below: the first runs daily, the second every hour.
schtasks /create /sc daily /st 23:50 /tn "Hua" /tr D:\Documents\Hua.bat
schtasks /create /sc hourly /st 08:05 /tn "Hua" /tr D:\Documents\Hua.bat
On Linux and Cygwin it's a little simpler since the batch script is not necessary. The equivalent cron jobs look like this:
50 23 * * * cd Hua; pwsh hua.ps1 hua.cfg
5 * * * * cd Hua; pwsh hua.ps1 hua.cfg
Note that in the case of Cygwin, you'll need to use the full path to pwsh:
50 23 * * * cd Hua; /cygdrive/c/PowerShell-7.4.6-win-x64/pwsh ./hua.ps1 ./hua.cfg
If you want to suppress Hua's output, direct it to /dev/null
as shown below. Output is still sent to Hua's log file.
50 23 * * * cd Hua; pwsh hua.ps1 hua.cfg > /dev/null
By William Jeffrey Rankin, Sat Nov 23 2024
Revision 195 includes improvements to Hua's handling of non-critical errors. These are instances where Hua will continue processing all content except for the suspect entries. Examples of this include zero-length (empty) article files, entries lacking a filename, and entries lacking an ID. When possible, the entry ID is shown so the record can be quickly located and fixed.
The latest Hua download package demonstrates these errors. For example:
jeffr@Callisto: ~/Documents/Hua $ pwsh ./hua.ps1 ./hua.cfg
Content file error. File (ID: 000045) is empty. Skipping.
Entries file error. There is an entry (ID: 000040) without a filename. Skipping.
...
Entries file error. There is an entry without an ID. Skipping.
By William Jeffrey Rankin, Mon Oct 14 2024
Revision 169 of Hua supports PDF generation through Pandoc and the GNU roff (groff) typesetting system. This allows for much better looking print output than is possible through HTML and CSS.
Groff output mode is used in conjunction with article mode:
.\hua.ps1 .\hua.cfg -A '00110' -G
This command outputs two files: the HTML version of the article and a version for use in groff (it's given an .ms
extension). To convert this file to PDF, run the following:
pdfroff -ms -mpdfmark -mspdf pandoc-int.html.ms > pandoc-int.html.pdf
The result looks like this (pandoc-int.html.pdf). Here's a more verbose example (old-church-stone.html.pdf). Note that only absolute links work in documents generated this way.
By William Jeffrey Rankin, Thu Sep 26 2024
As of revision 165, Hua has an article mode that enables processing of an individual article. This is useful in instances where an article is in development and requires review. In this mode only the specified article is generated; index, archive, and tagged-with files are not touched. Since only one article is processed, this mode is significantly faster as well.
jeffr@CALLISTO: D:\Documents\wjr-blog $ Measure-Command { ..\Hua\hua.ps1 .\hua.cfg -A '00100' | Out-Default }
...
Seconds : 0
Milliseconds : 375
...
jeffr@CALLISTO: D:\Documents\wjr-blog $ Measure-Command { ..\Hua\hua.ps1 .\hua.cfg | Out-Default }
...
Seconds : 3
Milliseconds : 27
...
By William Jeffrey Rankin, Thu Sep 19 2024
As of revision 157 (released Sep 18, 2024) Hua outputs specific codes based upon error condition. Normally, if all goes well, Hua exits with a status of 0
. But when an error condition results, Hua outputs a message and, depending upon the severity of the error, either continues processing content or stops entirely. When the latter occurs, a non-zero exit status is generated. It can be output as seen in the examples below.
jeffr@CALLISTO: D:\Documents\wjr-blog $ ..\Hua\hua.ps1 .\wrong.cfg
Config file error. Config file path specified as .\wrong.cfg . Quitting.
jeffr@CALLISTO: D:\Documents\wjr-blog $ $LASTEXITCODE
2
jeffr@Phobos: ~/Hua $ pwsh ./hua.ps1 hua.cfg
Meta info file error. Meta file path set as .\met.csv. Quitting.
jeffr@Phobos: ~/Hua $ echo $?
9
This is useful in instances where Hua is invoked from a script or as part of a toolchain and exit status needs to be introspected. For more information, refer to the Errors section of the main Hua page.