Some HTML help cleanup.

This commit is contained in:
Scott Duensing 2026-04-13 22:34:15 -05:00
parent 8abe947b8b
commit 66952306df
4 changed files with 848 additions and 1002 deletions

File diff suppressed because it is too large Load diff

View file

@ -53,12 +53,11 @@ img { max-width: 100%; }
<main>
<div class="topic" id="help.overview">
<h1>DVX Help Viewer</h1>
<h2>DVX Help Viewer</h2>
<p>The DVX Help Viewer displays .hlp help files compiled from .dhs source documents. It provides a tree-based table of contents, scrollable content with word-wrapped text, clickable hyperlinks, full-text search, and a keyword index.</p>
<h3>Opening Help</h3>
<h2>Opening Help</h2>
<p>Press F1 from any DVX application to open context-sensitive help. Applications can register their own help file and topic so F1 opens the relevant page.</p>
<p>You can also launch the help viewer from an application's Help menu, or by clicking the DVX Help icon in the Program Manager.</p>
<h3>Navigation</h3>
<h2>Navigation</h2>
<ul>
<li>Click a topic in the tree on the left to display it</li>
<li>Click underlined links in the content to jump to other topics</li>
@ -66,7 +65,7 @@ img { max-width: 100%; }
<li>Use Navigate &gt; Index to browse an alphabetical keyword list</li>
</ul>
<p>Use Navigate &gt; Search to find topics by keyword</p>
<h3>Keyboard Shortcuts</h3>
<h2>Keyboard Shortcuts</h2>
<pre> Alt+Left Back
Alt+Right Forward
Ctrl+F Search
@ -74,21 +73,20 @@ img { max-width: 100%; }
</div>
<div class="topic" id="help.format">
<h1>Help Source Format (.dhs)</h1>
<h2>Help Source Format (.dhs)</h2>
<p>Help files are authored as plain text .dhs source files using a simple line-oriented directive format. Lines beginning with a period at column 0 are directives. All other lines are body text, which is automatically word-wrapped by the viewer at display time.</p>
<h3>Topic Directives</h3>
<h2>Topic Directives</h2>
<pre> .topic &lt;id&gt; Start a new topic with a unique string ID
.title &lt;text&gt; Set the topic's display title
.toc &lt;depth&gt; &lt;text&gt; Add a table of contents entry (0=root, 1=child, etc.)
.default Mark this topic as the one shown when the file opens</pre>
<h3>Content Directives</h3>
<h2>Content Directives</h2>
<pre> .h1 &lt;text&gt; Level 1 heading (colored bar)
.h2 &lt;text&gt; Level 2 heading (underlined)
.h3 &lt;text&gt; Level 3 heading (plain)
.hr Horizontal rule
.link &lt;id&gt; &lt;text&gt; Hyperlink to another topic
.image &lt;file.bmp&gt; Inline image (BMP format)</pre>
<h3>Block Directives</h3>
<h2>Block Directives</h2>
<pre> .list Start a bulleted list
.item &lt;text&gt; List item (must be inside .list)
.endlist End the bulleted list
@ -98,9 +96,9 @@ img { max-width: 100%; }
.endcode End code block
.note [info|tip|warning] Start a callout box
.endnote End callout box</pre>
<h3>Index Directives</h3>
<h2>Index Directives</h2>
<pre> .index &lt;keyword&gt; Add a keyword to the index pointing to this topic</pre>
<h3>Example</h3>
<h2>Example</h2>
<pre><code>.topic intro
.title Welcome
.toc 0 Welcome
@ -130,7 +128,7 @@ This is a helpful tip.
.note warning
This is a warning message.
.endnote</code></pre>
<h3>Callout Boxes</h3>
<h2>Callout Boxes</h2>
<p>Three types of callout boxes are available, each with a distinct colored accent bar:</p>
<blockquote><strong>Note:</strong> Use info notes for general supplementary information.</blockquote>
<blockquote><strong>Tip:</strong> Use tip notes for helpful suggestions and best practices.</blockquote>
@ -138,35 +136,33 @@ This is a warning message.
</div>
<div class="topic" id="help.compiler">
<h1>Help Compiler (dvxhlpc)</h1>
<h2>Help Compiler (dvxhlpc)</h2>
<p>The dvxhlpc tool runs on the host (Linux) and compiles .dhs source files into binary .hlp files for the viewer, and optionally into self-contained HTML.</p>
<h3>Usage</h3>
<h2>Usage</h2>
<pre><code>dvxhlpc -o output.hlp [-i imagedir] [--html out.html] input.dhs [...]</code></pre>
<h3>Options</h3>
<h2>Options</h2>
<pre> -o output.hlp Output binary help file (required)
-i imagedir Directory to find .image files (default: current dir)
--html out.html Also emit a self-contained HTML file</pre>
<p>Multiple input files are merged into a single help file. This allows per-widget or per-feature documentation fragments to be combined automatically.</p>
<h3>Build Integration</h3>
<h2>Build Integration</h2>
<p>The standard build pattern globs all fragments:</p>
<pre><code>dvxhlpc -o dvxhelp.hlp docs/src/overview.dhs widgets/*/*.dhs</code></pre>
<p>New widgets or features just drop a .dhs file in their source directory and it appears in the help on the next build.</p>
<h3>HTML Output</h3>
<h2>HTML Output</h2>
<p>The --html flag produces a single self-contained HTML file with a sidebar table of contents, styled headings, lists, code blocks, notes, and embedded images (base64 data URIs). This is useful for viewing documentation on the host machine without running the DOS help viewer.</p>
</div>
<div class="topic" id="help.integration">
<h1>Application Integration</h1>
<h2>Application Integration</h2>
<p>Any DVX application can provide context-sensitive help via the F1 key.</p>
<h3>Setting Up Help</h3>
<h2>Setting Up Help</h2>
<p>In your appMain, set the help file path on the app context:</p>
<pre><code>snprintf(ctx-&gt;helpFile, sizeof(ctx-&gt;helpFile),
&quot;%s%cMYAPP.HLP&quot;, ctx-&gt;appDir, DVX_PATH_SEP);</code></pre>
<h3>Context-Sensitive Topics</h3>
<h2>Context-Sensitive Topics</h2>
<p>Update helpTopic as the user navigates your application:</p>
<pre><code>snprintf(ctx-&gt;helpTopic, sizeof(ctx-&gt;helpTopic), &quot;settings.video&quot;);</code></pre>
<p>When the user presses F1, the shell launches the help viewer with your help file opened to the specified topic.</p>
<h3>Launching Help from Menus</h3>
<h2>Launching Help from Menus</h2>
<p>To add a Help menu item that opens your help file:</p>
<pre><code>shellLoadAppWithArgs(ctx, viewerPath, helpFilePath);</code></pre>
</div>

File diff suppressed because it is too large Load diff

View file

@ -1201,7 +1201,27 @@ static void htmlWriteImage(FILE *f, const RecordT *rec) {
fclose(imgFile);
fprintf(f, "<p><img src=\"data:image/bmp;base64,");
// Detect MIME type from file extension
const char *mime = "image/bmp";
const char *dot = strrchr(rec->data, '.');
if (dot) {
if (strcasecmp(dot, ".png") == 0) { mime = "image/png"; }
else if (strcasecmp(dot, ".jpg") == 0 ||
strcasecmp(dot, ".jpeg") == 0) { mime = "image/jpeg"; }
else if (strcasecmp(dot, ".gif") == 0) { mime = "image/gif"; }
}
// Alignment from record flags
const char *alignStyle = "";
if (rec->flags == HLP_IMG_CENTER) {
alignStyle = " style=\"text-align:center\"";
} else if (rec->flags == HLP_IMG_RIGHT) {
alignStyle = " style=\"text-align:right\"";
}
fprintf(f, "<p%s><img src=\"data:%s;base64,", alignStyle, mime);
base64Encode(f, imgData, (int32_t)imgSize);
fprintf(f, "\" alt=\"%s\"></p>\n", rec->data);
free(imgData);
@ -1228,23 +1248,23 @@ static void htmlWriteRecords(FILE *f, const TopicT *topic) {
break;
case HLP_REC_HEADING1:
fprintf(f, "<h1>");
htmlEscapeWrite(f, rec->data);
fprintf(f, "</h1>\n");
break;
case HLP_REC_HEADING2:
fprintf(f, "<h2>");
htmlEscapeWrite(f, rec->data);
fprintf(f, "</h2>\n");
break;
case HLP_REC_HEADING2:
case HLP_REC_HEADING3:
fprintf(f, "<h3>");
htmlEscapeWrite(f, rec->data);
fprintf(f, "</h3>\n");
break;
case HLP_REC_HEADING3:
fprintf(f, "<h4>");
htmlEscapeWrite(f, rec->data);
fprintf(f, "</h4>\n");
break;
case HLP_REC_IMAGE:
htmlWriteImage(f, rec);
break;
@ -1442,9 +1462,6 @@ static int emitHtml(const char *outputPath) {
for (int32_t i = 0; i < topicCount; i++) {
fprintf(f, "<div class=\"topic\" id=\"%s\">\n", topics[i].id);
fprintf(f, "<h1>");
htmlEscapeWrite(f, topics[i].title);
fprintf(f, "</h1>\n");
htmlWriteRecords(f, &topics[i]);
fprintf(f, "</div>\n");
}