#define D_DT (1 << 7)
#define D_DD (1 << 8)
#define D_PA (1 << 9)
+#define D_IL (1 << 10)
+#define D_TT (1 << 11)
enum
{
SP_START_EM,
SP_START_BF,
+ SP_START_TT,
SP_END_FT,
SP_NEWLINE,
SP_NEWPAR,
SP_DD,
SP_END_DD,
SP_END_DL,
+ SP_START_IL,
+ SP_END_IL,
SP_END_SECT,
SP_REFER
};
fputs ("\\(rq", out);
else if (*v == '\\')
fputs ("\\\\", out);
+ else if (*v == '-')
+ fputs ("\\-", out);
else
fputc (*v, out);
}
{
switch (c)
{
+ /* the bare minimum for escaping */
case '<': return fputs ("<", out);
case '>': return fputs (">", out);
- case '$': return fputs ("$", out);
- case '_': return fputs ("_", out);
- case '%': return fputs ("%", out);
case '&': return fputs ("&", out);
- case '\\': return fputs ("\", out);
- case '"': return fputs (""", out);
- case '[': return fputs ("[", out);
- case ']': return fputs ("]", out);
- case '~': return fputs ("˜", out);
default: return fputc (c, out);
}
}
for (; *s; s++)
if (sgml_fputc ((unsigned int) *s, out) == EOF)
return EOF;
-
+
return 0;
}
{
char id;
+ if (*s == '<')
+ s++;
+
for (; *s; s++)
{
if (*s == '_')
id = '-';
else
id = *s;
+ if (*s == '>' && !*(s+1))
+ break;
if (fputc ((unsigned int) id, out) == EOF)
return EOF;
man_print_strval (val, out);
fputs ("\\(rq\n", out);
}
- else
- fprintf (out, "Default: %s\n", val);
+ else {
+ fputs ("Default: ", out);
+ man_print_strval (val, out);
+ fputs ("\n", out);
+ }
fputs (".fi", out);
fputs ("\">\n<title>", out);
sgml_fputs (varname, out);
fprintf (out, "</title>\n<literallayout>Type: %s", type2human (type));
+
if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)
{
- fputs ("\nDefault: "", out);
- sgml_print_strval (val, out);
- fputs (""</literallayout>\n", out);
+ if (val && *val)
+ {
+ fputs ("\nDefault: <quote><literal>", out);
+ sgml_print_strval (val, out);
+ fputs ("</literal></quote>", out);
+ }
+ else
+ {
+ fputs ("\nDefault: (empty)", out);
+ }
+ fputs ("</literallayout>\n", out);
}
else
fprintf (out, "\nDefault: %s</literallayout>\n", val);
** - .dt starts a term in a definition list.
** - .dd starts a definition in a definition list.
** - .de on a line finishes a definition list.
+ ** - .il on a line starts an itemzied list
+ ** - .dd starts an item in an itemized list
+ ** - .ie on a line finishes an itemized list
** - .ts on a line starts a "tscreen" environment (name taken from SGML).
** - .te on a line finishes this environment.
** - .pp on a line starts a paragraph.
if (docstat & (D_DL))
docstat = print_it (SP_END_DL, NULL, out, docstat);
- if (docstat & (D_EM | D_BF))
+ if (docstat & (D_EM | D_BF | D_TT))
docstat = print_it (SP_END_FT, NULL, out, docstat);
docstat = print_it (SP_END_SECT, NULL, out, docstat);
{
static int Continuation = 0;
- case SP_END_FT: docstat &= ~(D_EM|D_BF); break;
+ case SP_END_FT: docstat &= ~(D_EM|D_BF|D_TT); break;
case SP_START_BF: docstat |= D_BF; break;
case SP_START_EM: docstat |= D_EM; break;
+ case SP_START_TT: docstat |= D_TT; break;
case SP_NEWLINE:
{
if (onl)
}
case SP_DD:
{
+ if (docstat & D_IL)
+ fputs ("- ", out);
Continuation = 0;
break;
}
docstat &= ~D_DL;
break;
}
+ case SP_START_IL:
+ {
+ docstat |= D_IL;
+ break;
+ }
+ case SP_END_IL:
+ {
+ Continuation = 0;
+ docstat &= ~D_IL;
+ break;
+ }
case SP_STR:
{
if (Continuation)
case SP_END_FT:
{
fputs ("\\fP", out);
- docstat &= ~(D_EM|D_BF);
+ docstat &= ~(D_EM|D_BF|D_TT);
break;
}
case SP_START_BF:
{
fputs ("\\fB", out);
docstat |= D_BF;
- docstat &= ~D_EM;
+ docstat &= ~(D_EM|D_TT);
break;
}
case SP_START_EM:
{
fputs ("\\fI", out);
docstat |= D_EM;
- docstat &= ~D_BF;
+ docstat &= ~(D_BF|D_TT);
break;
}
+ case SP_START_TT:
+ {
+ fputs ("\\fC", out);
+ docstat |= D_TT;
+ docstat &= ~(D_BF|D_EM);
+ break;
+ }
case SP_NEWLINE:
{
if (onl)
}
case SP_DD:
{
- fputs ("\n", out);
+ if (docstat & D_IL)
+ fputs (".TP\n\\(hy ", out);
+ else
+ fputs ("\n", out);
break;
}
case SP_END_DL:
docstat &= ~D_DL;
break;
}
+ case SP_START_IL:
+ {
+ fputs (".RS\n.PD 0\n", out);
+ docstat |= D_IL;
+ break;
+ }
+ case SP_END_IL:
+ {
+ fputs (".RE\n.PD 1", out);
+ docstat &= ~D_DL;
+ break;
+ }
case SP_STR:
{
while (*str)
fputs ("\\(rq", out);
else if (*str == '\\')
fputs ("\\\\", out);
+ else if (*str == '-')
+ fputs ("\\-", out);
else if (!strncmp (str, "``", 2))
{
fputs ("\\(lq", out);
{
if (docstat & D_EM) fputs ("</emphasis>", out);
if (docstat & D_BF) fputs ("</emphasis>", out);
- docstat &= ~(D_EM|D_BF);
+ if (docstat & D_TT) fputs ("</literal>", out);
+ docstat &= ~(D_EM|D_BF|D_TT);
break;
}
case SP_START_BF:
{
fputs ("<emphasis role=\"bold\">", out);
docstat |= D_BF;
- docstat &= ~D_EM;
+ docstat &= ~(D_EM|D_TT);
break;
}
case SP_START_EM:
{
fputs ("<emphasis>", out);
docstat |= D_EM;
- docstat &= ~D_BF;
+ docstat &= ~(D_BF|D_TT);
break;
}
+ case SP_START_TT:
+ {
+ fputs ("<literal>", out);
+ docstat |= D_TT;
+ docstat &= ~(D_BF|D_EM);
+ break;
+ }
case SP_NEWLINE:
{
if (onl)
}
case SP_START_TAB:
{
+ if (docstat & D_PA)
+ {
+ fputs ("\n</para>\n", out);
+ docstat &= ~D_PA;
+ }
fputs ("\n<screen>\n", out);
docstat |= D_TAB | D_NL;
break;
}
case SP_END_TAB:
{
- fputs ("\n</screen>", out);
+ fputs ("</screen>", out);
docstat &= ~D_TAB;
docstat |= D_NL;
break;
}
case SP_START_DL:
{
- fputs ("\n<variablelist>\n", out);
+ if (docstat & D_PA)
+ {
+ fputs ("\n</para>\n", out);
+ docstat &= ~D_PA;
+ }
+ fputs ("\n<informaltable>\n<tgroup cols=\"2\">\n<tbody>\n", out);
docstat |= D_DL;
break;
}
case SP_DT:
{
- fputs ("<varlistentry><term>", out);
+ fputs ("<row><entry>", out);
break;
}
case SP_DD:
{
docstat |= D_DD;
- fputs ("</term>\n<listitem><para>", out);
+ if (docstat & D_DL)
+ fputs("</entry><entry>", out);
+ else
+ fputs ("<listitem><para>", out);
break;
}
case SP_END_DD:
{
+ if (docstat & D_DL)
+ fputs ("</entry></row>\n", out);
+ else
+ fputs ("</para></listitem>", out);
docstat &= ~D_DD;
- fputs ("</para></listitem></varlistentry>\n", out);
break;
}
case SP_END_DL:
{
- fputs ("</para></listitem></varlistentry></variablelist>\n", out);
+ fputs ("</entry></row></tbody></tgroup></informaltable>\n", out);
+ docstat &= ~(D_DD|D_DL);
+ break;
+ }
+ case SP_START_IL:
+ {
+ if (docstat & D_PA)
+ {
+ fputs ("\n</para>\n", out);
+ docstat &= ~D_PA;
+ }
+ fputs ("\n<itemizedlist>\n", out);
+ docstat |= D_IL;
+ break;
+ }
+ case SP_END_IL:
+ {
+ fputs ("</para></listitem></itemizedlist>\n", out);
docstat &= ~(D_DD|D_DL);
break;
}
case SP_STR:
{
if (docstat & D_TAB)
- fputs (str, out);
- else
sgml_fputs (str, out);
+ else
+ {
+ while (*str)
+ {
+ for (; *str; str++)
+ {
+ if (!strncmp (str, "``", 2))
+ {
+ fputs ("<quote>", out);
+ str++;
+ }
+ else if (!strncmp (str, "''", 2))
+ {
+ fputs ("</quote>", out);
+ str++;
+ }
+ else
+ sgml_fputc (*str, out);
+ }
+ }
+ }
break;
}
}
sgml_id_fputs (ref, out);
fputs ("\">", out);
if (output_dollar)
- fputs ("$", out);
+ fputc ('$', out);
sgml_fputs (ref, out);
fputs ("</link>", out);
break;
return print_it (SP_START_DL, NULL, out, docstat);
else if (!strncmp (l, ".de", 3))
return print_it (SP_END_DL, NULL, out, docstat);
+ else if (!strncmp (l, ".il", 3))
+ return print_it (SP_START_IL, NULL, out, docstat);
+ else if (!strncmp (l, ".ie", 3))
+ return print_it (SP_END_IL, NULL, out, docstat);
else if (!strncmp (l, ". ", 2))
*l = ' ';
docstat = print_it (SP_START_BF, NULL, out, docstat);
s += 2;
}
+ else if (!strncmp (s, "\\fC", 3))
+ {
+ docstat = commit_buff (buff, &d, out, docstat);
+ docstat = print_it (SP_START_TT, NULL, out, docstat);
+ s += 2;
+ }
else if (!strncmp (s, "\\fP", 3))
{
docstat = commit_buff (buff, &d, out, docstat);
}
else if (!strncmp (s, ".dd", 3))
{
+ if ((docstat & D_IL) && (docstat & D_DD))
+ {
+ docstat = commit_buff (buff, &d, out, docstat);
+ docstat = print_it (SP_END_DD, NULL, out, docstat);
+ }
docstat = commit_buff (buff, &d, out, docstat);
docstat = print_it (SP_DD, NULL, out, docstat);
s += 3;
else
{
ref = s;
- while (isalnum ((unsigned char) *s) || *s == '-' || *s == '_')
+ while (isalnum ((unsigned char) *s) || (*s && strchr("-_<>", *s)))
++s;
docstat = commit_buff (buff, &d, out, docstat);