aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2023-11-02 05:40:14 +0000
committerNIIBE Yutaka <[email protected]>2023-11-02 05:40:14 +0000
commitc57e1b1435e6a09e547b18df6c458f9f32a1a513 (patch)
tree2659f342decfd20b5dde08855a4f5febfbbbfa3f
parentyat2m: Support Texinfo input -- and ---. (diff)
downloadlibgpg-error-c57e1b1435e6a09e547b18df6c458f9f32a1a513.tar.gz
libgpg-error-c57e1b1435e6a09e547b18df6c458f9f32a1a513.zip
yat2m: Interpret -- and --- verbatimly in @example.
* doc/yat2m.c (example_cmd_active): New. (proc_texi_cmd): Don't apply the processing for en-dash and em-dash when it's in @example/@smallexample. -- GnuPG-bug-id: 6746 Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--doc/yat2m.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/doc/yat2m.c b/doc/yat2m.c
index ebddba8..b5978e4 100644
--- a/doc/yat2m.c
+++ b/doc/yat2m.c
@@ -235,6 +235,8 @@ static int condition_stack_idx;
static int cond_is_active; /* State of ifset/ifclear */
static int cond_in_verbatim; /* State of "manverb". */
+/* Variable to check if it's in @example or @smallexample. */
+static int example_cmd_active;
/* Object to store one line of content. */
struct line_buffer_s
@@ -1280,8 +1282,8 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
{ "acronym", 0 },
{ "dfn", 0 },
{ "option", 0, "\\fB", "\\fR", "<samp>", "</samp>" },
- { "example", 1, ".RS 2\n.nf\n", NULL, "\n<pre>\n", "\n</pre>\n" },
- { "smallexample", 1, ".RS 2\n.nf\n", NULL, "\n<pre>\n", "\n</pre>\n" },
+ { "example", 10, ".RS 2\n.nf\n", NULL, "\n<pre>\n", "\n</pre>\n" },
+ { "smallexample", 10, ".RS 2\n.nf\n", NULL, "\n<pre>\n", "\n</pre>\n" },
{ "asis", 7 },
{ "anchor", 7 },
{ "cartouche", 1 },
@@ -1331,6 +1333,9 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
html_out = cmdtbl[i].html_out;
switch (cmdtbl[i].what)
{
+ case 10:
+ example_cmd_active = 1;
+ /* Fallthrough */
case 1: /* Throw away the entire line. */
s = memchr (rest, '\n', len);
return s? (s-rest)+1 : len;
@@ -1371,11 +1376,13 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
else if (n >= 7 && !memcmp (s, "example", 7)
&& (!n || s[7] == ' ' || s[7] == '\t' || s[7] == '\n'))
{
+ example_cmd_active = 0;
writestr (".fi\n.RE\n", "</pre>\n", fp);
}
else if (n >= 12 && !memcmp (s, "smallexample", 12)
&& (!n || s[12] == ' ' || s[12] == '\t' || s[12] == '\n'))
{
+ example_cmd_active = 0;
writestr (".fi\n.RE\n", "</pre>\n", fp);
}
else if (n >= 9 && !memcmp (s, "quotation", 9)
@@ -1627,7 +1634,7 @@ proc_texi_buffer (FILE *fp, const char *line, size_t len,
}
else if (*s == '\\')
writestr ("\\\\", "\\\\", fp);
- else if (sect && *s == '-')
+ else if (!example_cmd_active && sect && *s == '-')
/* Handle -- and --- when it's _not_ in an argument. */
{
if (len < 2 || s[1] != '-')