Meeseeks.data
You're seeing just the function
data
, go back to Meeseeks module for more information.
Specs
data(extractable(), Keyword.t()) :: String.t() | nil
Returns the combined data of a result or the result's children, which may be an empty string.
Once the data has been combined the whitespace is compacted by replacing all instances of more than one whitespace character with a single space and then trimmed.
Data is the content of <script>
or <style>
tags, or the content of
comments starting with "[CDATA[" and ending with "]]". The latter behavior
is to support the extraction of CDATA from HTML, since HTML5 parsers parse
CDATA as comments.
Nil input returns nil
.
Options
:collapse_whitespace
- Boolean determining whether or not to replace blocks of whitespace with a single space character. Defaults totrue
.:trim
- Boolean determining whether or not to trim the resulting text. Defaults totrue
.
Examples
iex> import Meeseeks.CSS
iex> result1 = Meeseeks.one("<div id=example>Hi</div>", css("#example"))
#Meeseeks.Result<{ <div id="example">Hi</div> }>
iex> Meeseeks.data(result1)
""
iex> result2 = Meeseeks.one("<script id=example>Hi</script>", css("#example"))
#Meeseeks.Result<{ <script id="example">Hi</script> }>
iex> Meeseeks.data(result2)
"Hi"