[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: html: @option inside @emph

From: Ralf Wildenhues
Subject: Re: html: @option inside @emph
Date: Sat, 10 Jun 2006 09:20:53 +0200
User-agent: Mutt/1.5.11+cvs20060403

* Karl Berry wrote on Thu, Jun 08, 2006 at 11:24:01PM CEST:
>     an @option inside an @emph causes a
>       <em>...<samp></em>...</samp>
> Drat.  Thanks for the test case, will look at it as soon as I can.

The problem is that the addition of <samp> happens too early, before the
rollback of emph (which leads to inserting </em>) can take place.

This immediate issue seems to be fixed by the hack below.  It's a hack
for several reasons, for example it can and does cause empty
<samp></samp> sequences to appear in the output.  (It can also cause
nested <samp>'s, which I think are allowed per standard; tidy complains
about them, but the w3 validator doesn't, so I guess a bug report
against tidy is in order now...)

I assume there to be lots more combinations which need treatment.
And for those, and a Nice Fix[tm] for the immediate issue, it seems
necessary to reevaluate two items:
1) which HTML tags can be nested, as per specification,
2) which text qualities do we _want_ to be nested?

An example for the second question: do you expect
  @emph{some @strong{strong and emphasized} text}

to be both italic and bold, or just bold, inside?  Do you expect
  @emph{use @code{ls -l} only}
  @emph{add @option{--foo} to the arguments}

to show code or options in italics?  Should the `&lsquo;' output
by cm_code for @samp be put inside <em> if inside @emph, with
  @emph{some @samp{code} sample}

Where it's pretty easy to decide the former, the latter two don't seem
so clear to me.  I think it may be necessary to make a number of such
decisions manually for some pairs of (outer, inner) tags.  If this
turns out to be powerful enough to improve highlighting, it could be
implemented quite easily by coding this as a set of rules for desired
and allowed nesting to feed insert_html_tag_with_attribute with, and
then solve the immediate bug that started this thread cleanly.

What do you think?


        * makeinfo/html.c (insert_html_tag_with_attribute): Treat `samp'
        special, to allow it to nest.
        * makeinfo/cmds.c (cm_code): use insert_html_tag to add `samp'
        instead of add_word, so that the roll-back of outer tags works

Index: makeinfo/cmds.c
RCS file: /cvsroot/texinfo/texinfo/makeinfo/cmds.c,v
retrieving revision 1.64
diff -u -r1.64 cmds.c
--- makeinfo/cmds.c     5 May 2006 16:31:37 -0000       1.64
+++ makeinfo/cmds.c     9 Jun 2006 22:02:08 -0000
@@ -837,12 +837,12 @@
             { /* If @samp specifically, add quotes a la TeX output.  */
               if (STREQ (command, "samp"))
                add_word ("&lsquo;");
-              add_word ("<samp>");
+             insert_html_tag (arg, "samp");
           insert_html_tag_with_attribute (arg, "span", "class=\"%s\"",command);
           if (arg == END)
-              add_word ("</samp>");
+             insert_html_tag (arg, "samp");
               if (STREQ (command, "samp"))
                add_word ("&rsquo;");
Index: makeinfo/html.c
RCS file: /cvsroot/texinfo/texinfo/makeinfo/html.c,v
retrieving revision 1.34
diff -u -r1.34 html.c
--- makeinfo/html.c     1 Jun 2006 23:48:33 -0000       1.34
+++ makeinfo/html.c     9 Jun 2006 22:02:08 -0000
@@ -557,6 +557,7 @@
   /* texinfo.tex doesn't support more than one font attribute
      at the same time.  */
   if ((start_or_end == START) && old_tag && *old_tag
+      && !STREQ (old_tag, "samp")
       && !rollback_empty_tag (old_tag))
     add_word_args ("</%s>", old_tag);
@@ -564,13 +565,13 @@
       if (start_or_end == START)
         add_word_args (format ? "<%s %s>" : "<%s>", tag, formatted_attribs);
-      else if (!rollback_empty_tag (tag))
+      else if (STREQ (tag, "samp") || !rollback_empty_tag (tag))
         /* Insert close tag only if we didn't rollback,
            in which case the opening tag is removed.  */
         add_word_args ("</%s>", tag);
-  if ((start_or_end != START) && old_tag && *old_tag)
+  if ((start_or_end != START) && old_tag && *old_tag && !STREQ (old_tag, 
     add_word_args (strlen (old_attribs) > 0 ? "<%s %s>" : "<%s>",
         old_tag, old_attribs);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]