Loading ...
Sorry, an error occurred while loading the content.

Problem with syntax/html.vim

Expand Messages
  • Gary Johnson
    I was editing an HTML file (the contents of an Outlook message) when I noticed that the syntax highlighting was messed up in certain regions. The problem can
    Message 1 of 3 , May 16 11:32 PM
    • 0 Attachment
      I was editing an HTML file (the contents of an Outlook message) when
      I noticed that the syntax highlighting was messed up in certain
      regions. The problem can be seen when the following snippet is
      highlighted as HTML.

      <html>
      <head>

      <!--[if gte mso 9]><xml>
      <m:brkBin m:val="before"/>
      <m:brkBinSub m:val="--"/>
      <m:lMargin m:val="0"/>
      <m:rMargin m:val="0"/>
      </xml><![endif]-->

      </head>
      </html>

      The highlighting is correct through the '--', but they incorrectly
      terminate the comment region. The following '"/' are highlighted as
      an error, as are '[endif]', and the </head> and </html> tags are
      highlighted as comments.

      The problem seems to be this line in $VIMRUNTIME/syntax/html.vim
      (dated 2012 Oct 05),

      syn region htmlCommentPart contained start=+--+ end=+--\s*+ contains=@htmlPreProc,@Spell

      which doesn't account for the possibility of '--' being anywhere
      within a string.

      I don't know enough about syntax highlighting to know how to fix it,
      though, and I would rather help the author with a solution than just
      point out the problem, so I thought I'd ask here if anyone knew of a
      solution. (I have Bcc'd the author.)

      Regards,
      Gary

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • glts
      Gary, ... Double dash isn t allowed in XML comments. I think the highlighting is correct as it is. -- -- You received this message from the vim_use maillist.
      Message 2 of 3 , May 17 2:11 AM
      • 0 Attachment
        Gary,

        On Friday, May 17, 2013 8:32:36 AM UTC+2, Gary Johnson wrote:
        > The highlighting is correct through the '--', but they incorrectly
        > terminate the comment region. The following '"/' are highlighted as
        > an error, as are '[endif]', and the </head> and </html> tags are
        > highlighted as comments.
        >
        > The problem seems to be this line in $VIMRUNTIME/syntax/html.vim
        > (dated 2012 Oct 05),
        >
        > syn region htmlCommentPart contained start=+--+ end=+--\s*+ contains=@htmlPreProc,@Spell
        >
        > which doesn't account for the possibility of '--' being anywhere
        > within a string.
        >
        > I don't know enough about syntax highlighting to know how to fix it,
        > though, and I would rather help the author with a solution than just
        > point out the problem, so I thought I'd ask here if anyone knew of a
        > solution. (I have Bcc'd the author.)

        Double dash isn't allowed in XML comments. I think the highlighting is
        correct as it is.

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Gary Johnson
        ... Thank you. Your answer prompted me to do a little research which confirmed it. http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4
        Message 3 of 3 , May 17 11:09 AM
        • 0 Attachment
          On 2013-05-17, glts wrote:
          > Gary,
          >
          > On Friday, May 17, 2013 8:32:36 AM UTC+2, Gary Johnson wrote:
          > > The highlighting is correct through the '--', but they incorrectly
          > > terminate the comment region. The following '"/' are highlighted as
          > > an error, as are '[endif]', and the </head> and </html> tags are
          > > highlighted as comments.
          > >
          > > The problem seems to be this line in $VIMRUNTIME/syntax/html.vim
          > > (dated 2012 Oct 05),
          > >
          > > syn region htmlCommentPart contained start=+--+ end=+--\s*+ contains=@htmlPreProc,@Spell
          > >
          > > which doesn't account for the possibility of '--' being anywhere
          > > within a string.
          > >
          > > I don't know enough about syntax highlighting to know how to fix it,
          > > though, and I would rather help the author with a solution than just
          > > point out the problem, so I thought I'd ask here if anyone knew of a
          > > solution. (I have Bcc'd the author.)
          >
          > Double dash isn't allowed in XML comments. I think the highlighting is
          > correct as it is.

          Thank you. Your answer prompted me to do a little research which
          confirmed it.

          http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4
          http://stackoverflow.com/questions/442786/are-nested-html-comments-possible

          So, Outlook generates invalid HTML. What a surprise.

          I have a workaround, so I'll use that when syntax highlighting
          Outlook messages.

          Regards,
          Gary

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.