diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2018-04-14 17:14:01 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2018-04-14 17:14:01 +0200 |
commit | e20d7381ee85611f9e1d1e6bef4fe2d7e2ae7780 (patch) | |
tree | 9eb74901b854761d09426492e47de54f5e8e5ed4 /lisp/xml.el | |
parent | db71b3182778b66fad3865825777b06cc20b89a8 (diff) | |
download | emacs-e20d7381ee85611f9e1d1e6bef4fe2d7e2ae7780.tar.gz |
Make DISCARD-COMMENTS in `libxml-parse-{html,xml}-region' obsolete
* doc/lispref/text.texi (Parsing HTML/XML): Mention that
discard-comments is obsolete.
* lisp/xml.el (xml-remove-comments): New function (bug#27178).
* src/xml.c (Flibxml_parse_html_region): Clarify what
DISCARD-COMMENTS actually does, and say that the parameter is
obsolete.
(Flibxml_parse_xml_region): Ditto.
Diffstat (limited to 'lisp/xml.el')
-rw-r--r-- | lisp/xml.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/xml.el b/lisp/xml.el index 3bc8c08cb7b..6ce944ccb82 100644 --- a/lisp/xml.el +++ b/lisp/xml.el @@ -1073,6 +1073,19 @@ The first line is indented with INDENT-STRING." (insert ?\n indent-string)) (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>)))) +;;;###autoload +(defun xml-remove-comments (beg end) + "Remove XML/HTML comments in the region between BEG and END. +All text between the <!-- ... --> markers will be removed." + (save-excursion + (save-restriction + (narrow-to-region beg end) + (goto-char beg) + (while (search-forward "<!--" nil t) + (let ((start (match-beginning 0))) + (when (search-forward "-->" nil t) + (delete-region start (point)))))))) + (provide 'xml) ;;; xml.el ends here |