Current section
Files
Jump to
Current section
Files
src/css_select.erl
-module(css_select).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/css_select.gleam").
-export([parse_simple_selector/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/css_select.gleam", 14).
?DOC(
" Parse a CSS selector string into a `Selector`.\n"
"\n"
" Returns an error if the input is not a valid simple selector\n"
" (no combinators like `>`, `+`, `~`, ` `).\n"
"\n"
" If you need a parse many expressions it is recommended to use the `parser` module instead\n"
" ```gleam\n"
" css_select.parse_simple_selector(\"div#foo.bar\")\n"
" // -> Ok(ElementSelector(Tag(\"div\"), [Id(\"foo\"), Class(\"bar\")]))\n"
" ```\n"
).
-spec parse_simple_selector(binary()) -> {ok, css_select@selector:selector()} |
{error, css_select@parser:parse_error()}.
parse_simple_selector(Input) ->
css_select@parser:parse(css_select@parser:new(), Input).