/*
- * "$Id: mantohtml.c 11818 2014-04-15 20:56:19Z msweet $"
+ * "$Id: mantohtml.c 12363 2014-12-12 19:51:33Z msweet $"
*
* Man page to HTML conversion program.
*
*outfile; /* Output file */
char line[1024], /* Line from file */
*lineptr, /* Pointer into line */
+ anchor[1024], /* Anchor */
name[1024], /* Man page name */
ddpost[256]; /* Tagged list post markup */
int section = -1, /* Man page section */
"\t<link rel=\"stylesheet\" type=\"text/css\" "
"href=\"../cups-printable.css\">\n", outfile);
+ anchor[0] = '\0';
+
while (fgets(line, sizeof(line), infile))
{
size_t linelen = strlen(line); /* Length of line */
else
fputs("<h3><a name=\"", outfile);
- for (lineptr = line + 4; *lineptr; lineptr ++)
- if (*lineptr == '\"')
- continue;
- else if (isalnum(*lineptr & 255))
- html_putc(*lineptr, outfile);
- else
- html_putc('_', outfile);
+ if (anchor[0])
+ {
+ fputs(anchor, outfile);
+ anchor[0] = '\0';
+ }
+ else
+ {
+ for (lineptr = line + 4; *lineptr; lineptr ++)
+ if (*lineptr == '\"')
+ continue;
+ else if (isalnum(*lineptr & 255))
+ html_putc(*lineptr, outfile);
+ else
+ html_putc('_', outfile);
+ }
fputs("\">", outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 3, "b", "b", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 3, "i", "i", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, "b", "i", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, "b", NULL, outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, "i", "b", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, "i", NULL, outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, NULL, "b", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, NULL, "i", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, "small", "b", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
fputs(end_fonts[font], outfile);
font = 0;
+ if (anchor[0])
+ fprintf(outfile, "<a name=\"%s\">", anchor);
+
html_alternate(line + 4, "small", "small", outfile);
+ if (anchor[0])
+ {
+ fputs("</a>", outfile);
+ anchor[0] = '\0';
+ }
+
if (post)
{
fputs(post, outfile);
}
fputs("<p>", outfile);
+
+ if (anchor[0])
+ {
+ fprintf(outfile, "<a name=\"%s\"></a>", anchor);
+ anchor[0] = '\0';
+ }
}
else if (!strcmp(line, ".RS") || !strncmp(line, ".RS ", 4))
{
fprintf(outfile, "<p style=\"margin-left: %.1fem; text-indent: %.1fem\">", amount, -amount);
+ if (anchor[0])
+ {
+ fprintf(outfile, "<a name=\"%s\"></a>", anchor);
+ anchor[0] = '\0';
+ }
+
if (line[1] == 'T')
post = "<br>\n";
}
fputs("<dt>", outfile);
snprintf(ddpost, sizeof(ddpost), "<dd style=\"margin-left: %.1fem\">", amount);
post = ddpost;
+
+ if (anchor[0])
+ {
+ fprintf(outfile, "<a name=\"%s\"></a>", anchor);
+ anchor[0] = '\0';
+ }
}
else if (!strncmp(line, ".IP ", 4))
{
fprintf(outfile, "<li style=\"margin-left: %.1fem;\">", amount);
else
fprintf(outfile, "<p style=\"margin-left: %.1fem;\">", amount);
+
+ if (anchor[0])
+ {
+ fprintf(outfile, "<a name=\"%s\"></a>", anchor);
+ anchor[0] = '\0';
+ }
}
else if (!strncmp(line, ".br", 3))
{
*/
}
#endif /* 0 */
+ else if (!strncmp(line, ".\\\"#", 4))
+ {
+ /*
+ * Anchor for HTML output...
+ */
+
+ strlcpy(anchor, line + 4, sizeof(anchor));
+ }
else if (strncmp(line, ".\\\"", 3))
{
/*
/*
- * End of "$Id: mantohtml.c 11818 2014-04-15 20:56:19Z msweet $".
+ * End of "$Id: mantohtml.c 12363 2014-12-12 19:51:33Z msweet $".
*/