]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - man/mantohtml.c
Import CUPS v2.0.2
[thirdparty/cups.git] / man / mantohtml.c
index 6811f0b90103e26924778d3ea7178b405d20e2c5..798b03ebca2dfd8ef96f974e8585f45dc55906e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$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.
  *
@@ -53,6 +53,7 @@ main(int  argc,                               /* I - Number of command-line args */
                *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 */
@@ -114,6 +115,8 @@ main(int  argc,                             /* I - Number of command-line args */
        "\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 */
@@ -176,13 +179,21 @@ main(int  argc,                           /* I - Number of command-line args */
        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);
 
@@ -221,8 +232,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -238,8 +258,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -255,8 +284,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -272,8 +310,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -289,8 +336,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -306,8 +362,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -323,8 +388,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -340,8 +414,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -357,8 +440,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -374,8 +466,17 @@ main(int  argc,                            /* I - Number of command-line args */
        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);
@@ -398,6 +499,12 @@ main(int  argc,                            /* I - Number of command-line args */
         }
 
        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))
       {
@@ -467,6 +574,12 @@ main(int  argc,                            /* I - Number of command-line args */
 
         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";
       }
@@ -502,6 +615,12 @@ main(int  argc,                            /* I - Number of command-line args */
         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))
       {
@@ -585,6 +704,12 @@ main(int  argc,                            /* I - Number of command-line args */
           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))
       {
@@ -686,6 +811,14 @@ main(int  argc,                            /* I - Number of command-line args */
        */
       }
 #endif /* 0 */
+      else if (!strncmp(line, ".\\\"#", 4))
+      {
+       /*
+        * Anchor for HTML output...
+        */
+
+        strlcpy(anchor, line + 4, sizeof(anchor));
+      }
       else if (strncmp(line, ".\\\"", 3))
       {
        /*
@@ -1088,5 +1221,5 @@ strmove(char       *d,                    /* I - Destination */
 
 
 /*
- * 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 $".
  */