unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Sean McAfee <eefacm@gmail.com>
Cc: 27178@debbugs.gnu.org
Subject: bug#27178: 26.0.50; libxml-parse-*-region functions ignore discard-comments argument
Date: Sat, 10 Jun 2017 11:50:06 -0400	[thread overview]
Message-ID: <877f0jx2oh.fsf@users.sourceforge.net> (raw)
In-Reply-To: <CANan03a5WPJddrCdFQztzKTVscp1+OjJ_NckfCgETsdredBjCw@mail.gmail.com> (Sean McAfee's message of "Wed, 31 May 2017 17:07:03 -0700")

retitle 27178 libxml-parse-*-region functions discard-comments argument only applies to top level comments
found 27178 25.2
tags 27178 confirmed
quit

Sean McAfee <eefacm@gmail.com> writes:

> The libxml-parse-html-region and libxml-parse-xml-region functions both
> appear to ignore their discard-comments parameters.
>
> When I enter the following text in a buffer and mark it:
>
>   <p>This <!-- and --> that</p>
>
> Then the result of evaluating the expression
>
>   (libxml-parse-html-region (mark) (point) nil t)
>
> is
>
>   (html nil (body nil (p nil "This " (comment nil " and ") " that")))
>
> and the result of evaluating the expression
>
>   (libxml-parse-xml-region (mark) (point) nil t)
>
> is
>
>   (p nil "This " (comment nil " and ") " that")
>
> In both cases, I would expect that passing t as the fourth argument
> would cause the comments to be dropped, but they are not.

It doesn't quite ignore that argument, but it only applies to top level
comments.  I think it's the implementation level leaking through.  See
in xml.c:

    static Lisp_Object
    parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url,
              Lisp_Object discard_comments, bool htmlp)
    {
        ...
        /* The document doesn't have toplevel comments or we discarded
           them.  Get the tree the proper way. */
        xmlNode *node = xmlDocGetRootElement (doc);

Apparently the "proper" way already discards top level comments, so the
DISCARD-COMMENTS parameter was added to be able to control this.  Maybe
we should just update the docs to match the code though, not sure.


> Incidentally, I notice that the documentation for
> libxml-parse-xml-region includes the following sentence:
>
>   If DISCARD-COMMENTS is non-nil, all HTML comments are discarded.
>
> I imagine this ought to refer to "XML comments" rather than "HTML
> comments."

Yeah, looks like copy-pasta from libxml-parse-html-region.





  reply	other threads:[~2017-06-10 15:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01  0:07 bug#27178: 26.0.50; libxml-parse-*-region functions ignore discard-comments argument Sean McAfee
2017-06-10 15:50 ` npostavs [this message]
2018-04-13 22:54   ` Lars Ingebrigtsen
2018-04-14  6:49     ` Eli Zaretskii
2018-04-14 13:11       ` Lars Ingebrigtsen
2018-04-14 13:28         ` Eli Zaretskii
2018-04-14 13:54           ` Lars Ingebrigtsen
2018-04-14 15:00             ` Eli Zaretskii
2018-04-14 15:14               ` Lars Ingebrigtsen
2018-04-14 15:17               ` Noam Postavsky
2018-04-14 15:21                 ` Lars Ingebrigtsen
2018-04-14 15:35                   ` Eli Zaretskii
2018-04-14 15:43                     ` Lars Ingebrigtsen
2018-04-14 16:24                       ` Eli Zaretskii
2018-04-14 15:35                   ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877f0jx2oh.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=27178@debbugs.gnu.org \
    --cc=eefacm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).