Make start/end in libxml-parse-html-region optional
* doc/lispref/text.texi (Parsing HTML/XML): Adjust. * src/xml.c (parse_region): Default start/end to point-min/point-max. (Flibxml_parse_html_region, Flibxml_parse_xml_region): Make start/end optional.
This commit is contained in:
parent
b04ec9a7d3
commit
cc33c6cf3a
2 changed files with 19 additions and 4 deletions
|
@ -5473,12 +5473,15 @@ available in this Emacs session.
|
||||||
When libxml2 support is available, the following functions can be used
|
When libxml2 support is available, the following functions can be used
|
||||||
to parse HTML or XML text into Lisp object trees.
|
to parse HTML or XML text into Lisp object trees.
|
||||||
|
|
||||||
@defun libxml-parse-html-region start end &optional base-url discard-comments
|
@defun libxml-parse-html-region &optional start end base-url discard-comments
|
||||||
This function parses the text between @var{start} and @var{end} as
|
This function parses the text between @var{start} and @var{end} as
|
||||||
HTML, and returns a list representing the HTML @dfn{parse tree}. It
|
HTML, and returns a list representing the HTML @dfn{parse tree}. It
|
||||||
attempts to handle real-world HTML by robustly coping with syntax
|
attempts to handle real-world HTML by robustly coping with syntax
|
||||||
mistakes.
|
mistakes.
|
||||||
|
|
||||||
|
If @var{start} or @var{end} are @code{nil}, they default to the values
|
||||||
|
from @code{point-min} and @code{point-max}, respectively.
|
||||||
|
|
||||||
The optional argument @var{base-url}, if non-@code{nil}, should be a
|
The optional argument @var{base-url}, if non-@code{nil}, should be a
|
||||||
string specifying the base URL for relative URLs occurring in links.
|
string specifying the base URL for relative URLs occurring in links.
|
||||||
|
|
||||||
|
@ -5524,7 +5527,7 @@ buffer. The argument @var{dom} should be a list as generated by
|
||||||
@end defun
|
@end defun
|
||||||
|
|
||||||
@cindex parsing xml
|
@cindex parsing xml
|
||||||
@defun libxml-parse-xml-region start end &optional base-url discard-comments
|
@defun libxml-parse-xml-region &optional start end base-url discard-comments
|
||||||
This function is the same as @code{libxml-parse-html-region}, except
|
This function is the same as @code{libxml-parse-html-region}, except
|
||||||
that it parses the text as XML rather than HTML (so it is stricter
|
that it parses the text as XML rather than HTML (so it is stricter
|
||||||
about syntax).
|
about syntax).
|
||||||
|
|
16
src/xml.c
16
src/xml.c
|
@ -186,6 +186,12 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url,
|
||||||
|
|
||||||
xmlCheckVersion (LIBXML_VERSION);
|
xmlCheckVersion (LIBXML_VERSION);
|
||||||
|
|
||||||
|
if (NILP (start))
|
||||||
|
start = Fpoint_min ();
|
||||||
|
|
||||||
|
if (NILP (end))
|
||||||
|
end = Fpoint_max ();
|
||||||
|
|
||||||
validate_region (&start, &end);
|
validate_region (&start, &end);
|
||||||
|
|
||||||
istart = XFIXNUM (start);
|
istart = XFIXNUM (start);
|
||||||
|
@ -269,8 +275,11 @@ xml_cleanup_parser (void)
|
||||||
|
|
||||||
DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region,
|
DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region,
|
||||||
Slibxml_parse_html_region,
|
Slibxml_parse_html_region,
|
||||||
2, 4, 0,
|
0, 4, 0,
|
||||||
doc: /* Parse the region as an HTML document and return the parse tree.
|
doc: /* Parse the region as an HTML document and return the parse tree.
|
||||||
|
If START is nil, it defaults to `point-min'. If END is nil, it
|
||||||
|
defaults to `point-max'.
|
||||||
|
|
||||||
If BASE-URL is non-nil, it is used to expand relative URLs.
|
If BASE-URL is non-nil, it is used to expand relative URLs.
|
||||||
|
|
||||||
If you want comments to be stripped, use the `xml-remove-comments'
|
If you want comments to be stripped, use the `xml-remove-comments'
|
||||||
|
@ -284,8 +293,11 @@ function to strip comments before calling this function. */)
|
||||||
|
|
||||||
DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region,
|
DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region,
|
||||||
Slibxml_parse_xml_region,
|
Slibxml_parse_xml_region,
|
||||||
2, 4, 0,
|
0, 4, 0,
|
||||||
doc: /* Parse the region as an XML document and return the parse tree.
|
doc: /* Parse the region as an XML document and return the parse tree.
|
||||||
|
If START is nil, it defaults to `point-min'. If END is nil, it
|
||||||
|
defaults to `point-max'.
|
||||||
|
|
||||||
If BASE-URL is non-nil, it is used to expand relative URLs.
|
If BASE-URL is non-nil, it is used to expand relative URLs.
|
||||||
|
|
||||||
If you want comments to be stripped, use the `xml-remove-comments'
|
If you want comments to be stripped, use the `xml-remove-comments'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue