CSSEx.Parser (CSSEx v0.6.6) View Source

The parser module that generates or writes a CSS file based on an entry file.

Link to this section Summary

Functions

Parses a String.t or a charlist and returns {:ok, %CSSEx.Parser{}, content_or_empty_list} or {:error, %CSSEx.Parser{}}. If a file path is passed as the final argument it returns the :ok tuple with an empty list instead of the content and writes into the file path. On error it returns an :error tuple with the %CSSEx.Parser{} having its :error key populated. If the first argument is a prefilled %CSSEx.Parser{} struct the parser uses that as its basis allowing to provide an ETS table that can be retrieved in the end, or passing predefined functions, assigns or variables, prefixes and etc into the context of the parser.

Takes a file path to a cssex or css file and parses it into a final CSS representation returning either

Link to this section Functions

Specs

parse(content :: String.t() | charlist()) ::
  {:ok,
   %CSSEx.Parser{
     answer_to: term(),
     assigns: term(),
     base_path: term(),
     charset: term(),
     column: term(),
     current_add_var: term(),
     current_assign: term(),
     current_chain: term(),
     current_function: term(),
     current_key: term(),
     current_reg: term(),
     current_scope: term(),
     current_value: term(),
     current_var: term(),
     dependencies: term(),
     error: term(),
     ets: term(),
     ets_fontface: term(),
     ets_keyframes: term(),
     expandables: term(),
     expandables_order_map: term(),
     file: term(),
     file_list: term(),
     first_rule: term(),
     font_face: term(),
     font_face_count: term(),
     functions: term(),
     imports: term(),
     keyframes_order_map: term(),
     level: term(),
     line: term(),
     local_assigns: term(),
     local_scope: term(),
     media: term(),
     media_parent: term(),
     no_count: term(),
     order_map: term(),
     page: term(),
     page_parent: term(),
     pass: term(),
     prefix: term(),
     scope: term(),
     search_acc: term(),
     source_pid: term(),
     split_chain: term(),
     supports: term(),
     supports_parent: term(),
     to_file: term(),
     valid?: true,
     warnings: term()
   }, String.t() | []}
  | {:error,
     %CSSEx.Parser{
       answer_to: term(),
       assigns: term(),
       base_path: term(),
       charset: term(),
       column: term(),
       current_add_var: term(),
       current_assign: term(),
       current_chain: term(),
       current_function: term(),
       current_key: term(),
       current_reg: term(),
       current_scope: term(),
       current_value: term(),
       current_var: term(),
       dependencies: term(),
       error: String.t(),
       ets: term(),
       ets_fontface: term(),
       ets_keyframes: term(),
       expandables: term(),
       expandables_order_map: term(),
       file: term(),
       file_list: term(),
       first_rule: term(),
       font_face: term(),
       font_face_count: term(),
       functions: term(),
       imports: term(),
       keyframes_order_map: term(),
       level: term(),
       line: term(),
       local_assigns: term(),
       local_scope: term(),
       media: term(),
       media_parent: term(),
       no_count: term(),
       order_map: term(),
       page: term(),
       page_parent: term(),
       pass: term(),
       prefix: term(),
       scope: term(),
       search_acc: term(),
       source_pid: term(),
       split_chain: term(),
       supports: term(),
       supports_parent: term(),
       to_file: term(),
       valid?: false,
       warnings: term()
     }}

Parses a String.t or a charlist and returns {:ok, %CSSEx.Parser{}, content_or_empty_list} or {:error, %CSSEx.Parser{}}. If a file path is passed as the final argument it returns the :ok tuple with an empty list instead of the content and writes into the file path. On error it returns an :error tuple with the %CSSEx.Parser{} having its :error key populated. If the first argument is a prefilled %CSSEx.Parser{} struct the parser uses that as its basis allowing to provide an ETS table that can be retrieved in the end, or passing predefined functions, assigns or variables, prefixes and etc into the context of the parser.

Specs

parse(
  base_config ::
    %CSSEx.Parser{
      answer_to: term(),
      assigns: term(),
      base_path: term(),
      charset: term(),
      column: term(),
      current_add_var: term(),
      current_assign: term(),
      current_chain: term(),
      current_function: term(),
      current_key: term(),
      current_reg: term(),
      current_scope: term(),
      current_value: term(),
      current_var: term(),
      dependencies: term(),
      error: term(),
      ets: term(),
      ets_fontface: term(),
      ets_keyframes: term(),
      expandables: term(),
      expandables_order_map: term(),
      file: term(),
      file_list: term(),
      first_rule: term(),
      font_face: term(),
      font_face_count: term(),
      functions: term(),
      imports: term(),
      keyframes_order_map: term(),
      level: term(),
      line: term(),
      local_assigns: term(),
      local_scope: term(),
      media: term(),
      media_parent: term(),
      no_count: term(),
      order_map: term(),
      page: term(),
      page_parent: term(),
      pass: term(),
      prefix: term(),
      scope: term(),
      search_acc: term(),
      source_pid: term(),
      split_chain: term(),
      supports: term(),
      supports_parent: term(),
      to_file: term(),
      valid?: term(),
      warnings: term()
    }
    | nil,
  content :: String.t() | charlist()
) ::
  {:ok,
   %CSSEx.Parser{
     answer_to: term(),
     assigns: term(),
     base_path: term(),
     charset: term(),
     column: term(),
     current_add_var: term(),
     current_assign: term(),
     current_chain: term(),
     current_function: term(),
     current_key: term(),
     current_reg: term(),
     current_scope: term(),
     current_value: term(),
     current_var: term(),
     dependencies: term(),
     error: term(),
     ets: term(),
     ets_fontface: term(),
     ets_keyframes: term(),
     expandables: term(),
     expandables_order_map: term(),
     file: term(),
     file_list: term(),
     first_rule: term(),
     font_face: term(),
     font_face_count: term(),
     functions: term(),
     imports: term(),
     keyframes_order_map: term(),
     level: term(),
     line: term(),
     local_assigns: term(),
     local_scope: term(),
     media: term(),
     media_parent: term(),
     no_count: term(),
     order_map: term(),
     page: term(),
     page_parent: term(),
     pass: term(),
     prefix: term(),
     scope: term(),
     search_acc: term(),
     source_pid: term(),
     split_chain: term(),
     supports: term(),
     supports_parent: term(),
     to_file: term(),
     valid?: true,
     warnings: term()
   }, String.t() | []}
  | {:error,
     %CSSEx.Parser{
       answer_to: term(),
       assigns: term(),
       base_path: term(),
       charset: term(),
       column: term(),
       current_add_var: term(),
       current_assign: term(),
       current_chain: term(),
       current_function: term(),
       current_key: term(),
       current_reg: term(),
       current_scope: term(),
       current_value: term(),
       current_var: term(),
       dependencies: term(),
       error: String.t(),
       ets: term(),
       ets_fontface: term(),
       ets_keyframes: term(),
       expandables: term(),
       expandables_order_map: term(),
       file: term(),
       file_list: term(),
       first_rule: term(),
       font_face: term(),
       font_face_count: term(),
       functions: term(),
       imports: term(),
       keyframes_order_map: term(),
       level: term(),
       line: term(),
       local_assigns: term(),
       local_scope: term(),
       media: term(),
       media_parent: term(),
       no_count: term(),
       order_map: term(),
       page: term(),
       page_parent: term(),
       pass: term(),
       prefix: term(),
       scope: term(),
       search_acc: term(),
       source_pid: term(),
       split_chain: term(),
       supports: term(),
       supports_parent: term(),
       to_file: term(),
       valid?: false,
       warnings: term()
     }}
Link to this function

parse(data, content, parse_to_file)

View Source

Specs

parse(
  base_config ::
    %CSSEx.Parser{
      answer_to: term(),
      assigns: term(),
      base_path: term(),
      charset: term(),
      column: term(),
      current_add_var: term(),
      current_assign: term(),
      current_chain: term(),
      current_function: term(),
      current_key: term(),
      current_reg: term(),
      current_scope: term(),
      current_value: term(),
      current_var: term(),
      dependencies: term(),
      error: term(),
      ets: term(),
      ets_fontface: term(),
      ets_keyframes: term(),
      expandables: term(),
      expandables_order_map: term(),
      file: term(),
      file_list: term(),
      first_rule: term(),
      font_face: term(),
      font_face_count: term(),
      functions: term(),
      imports: term(),
      keyframes_order_map: term(),
      level: term(),
      line: term(),
      local_assigns: term(),
      local_scope: term(),
      media: term(),
      media_parent: term(),
      no_count: term(),
      order_map: term(),
      page: term(),
      page_parent: term(),
      pass: term(),
      prefix: term(),
      scope: term(),
      search_acc: term(),
      source_pid: term(),
      split_chain: term(),
      supports: term(),
      supports_parent: term(),
      to_file: term(),
      valid?: term(),
      warnings: term()
    }
    | nil,
  content :: String.t() | charlist(),
  output_file :: String.t() | nil
) ::
  {:ok,
   %CSSEx.Parser{
     answer_to: term(),
     assigns: term(),
     base_path: term(),
     charset: term(),
     column: term(),
     current_add_var: term(),
     current_assign: term(),
     current_chain: term(),
     current_function: term(),
     current_key: term(),
     current_reg: term(),
     current_scope: term(),
     current_value: term(),
     current_var: term(),
     dependencies: term(),
     error: term(),
     ets: term(),
     ets_fontface: term(),
     ets_keyframes: term(),
     expandables: term(),
     expandables_order_map: term(),
     file: term(),
     file_list: term(),
     first_rule: term(),
     font_face: term(),
     font_face_count: term(),
     functions: term(),
     imports: term(),
     keyframes_order_map: term(),
     level: term(),
     line: term(),
     local_assigns: term(),
     local_scope: term(),
     media: term(),
     media_parent: term(),
     no_count: term(),
     order_map: term(),
     page: term(),
     page_parent: term(),
     pass: term(),
     prefix: term(),
     scope: term(),
     search_acc: term(),
     source_pid: term(),
     split_chain: term(),
     supports: term(),
     supports_parent: term(),
     to_file: term(),
     valid?: true,
     warnings: term()
   }, String.t() | []}
  | {:error,
     %CSSEx.Parser{
       answer_to: term(),
       assigns: term(),
       base_path: term(),
       charset: term(),
       column: term(),
       current_add_var: term(),
       current_assign: term(),
       current_chain: term(),
       current_function: term(),
       current_key: term(),
       current_reg: term(),
       current_scope: term(),
       current_value: term(),
       current_var: term(),
       dependencies: term(),
       error: String.t(),
       ets: term(),
       ets_fontface: term(),
       ets_keyframes: term(),
       expandables: term(),
       expandables_order_map: term(),
       file: term(),
       file_list: term(),
       first_rule: term(),
       font_face: term(),
       font_face_count: term(),
       functions: term(),
       imports: term(),
       keyframes_order_map: term(),
       level: term(),
       line: term(),
       local_assigns: term(),
       local_scope: term(),
       media: term(),
       media_parent: term(),
       no_count: term(),
       order_map: term(),
       page: term(),
       page_parent: term(),
       pass: term(),
       prefix: term(),
       scope: term(),
       search_acc: term(),
       source_pid: term(),
       split_chain: term(),
       supports: term(),
       supports_parent: term(),
       to_file: term(),
       valid?: false,
       warnings: term()
     }}
Link to this function

parse_file(base_path, file_path)

View Source

Specs

parse_file(path :: String.t(), file_path :: String.t()) ::
  {:ok,
   %CSSEx.Parser{
     answer_to: term(),
     assigns: term(),
     base_path: term(),
     charset: term(),
     column: term(),
     current_add_var: term(),
     current_assign: term(),
     current_chain: term(),
     current_function: term(),
     current_key: term(),
     current_reg: term(),
     current_scope: term(),
     current_value: term(),
     current_var: term(),
     dependencies: term(),
     error: term(),
     ets: term(),
     ets_fontface: term(),
     ets_keyframes: term(),
     expandables: term(),
     expandables_order_map: term(),
     file: term(),
     file_list: term(),
     first_rule: term(),
     font_face: term(),
     font_face_count: term(),
     functions: term(),
     imports: term(),
     keyframes_order_map: term(),
     level: term(),
     line: term(),
     local_assigns: term(),
     local_scope: term(),
     media: term(),
     media_parent: term(),
     no_count: term(),
     order_map: term(),
     page: term(),
     page_parent: term(),
     pass: term(),
     prefix: term(),
     scope: term(),
     search_acc: term(),
     source_pid: term(),
     split_chain: term(),
     supports: term(),
     supports_parent: term(),
     to_file: term(),
     valid?: term(),
     warnings: term()
   }, String.t()}
  | {:error,
     %CSSEx.Parser{
       answer_to: term(),
       assigns: term(),
       base_path: term(),
       charset: term(),
       column: term(),
       current_add_var: term(),
       current_assign: term(),
       current_chain: term(),
       current_function: term(),
       current_key: term(),
       current_reg: term(),
       current_scope: term(),
       current_value: term(),
       current_var: term(),
       dependencies: term(),
       error: String.t(),
       ets: term(),
       ets_fontface: term(),
       ets_keyframes: term(),
       expandables: term(),
       expandables_order_map: term(),
       file: term(),
       file_list: term(),
       first_rule: term(),
       font_face: term(),
       font_face_count: term(),
       functions: term(),
       imports: term(),
       keyframes_order_map: term(),
       level: term(),
       line: term(),
       local_assigns: term(),
       local_scope: term(),
       media: term(),
       media_parent: term(),
       no_count: term(),
       order_map: term(),
       page: term(),
       page_parent: term(),
       pass: term(),
       prefix: term(),
       scope: term(),
       search_acc: term(),
       source_pid: term(),
       split_chain: term(),
       supports: term(),
       supports_parent: term(),
       to_file: term(),
       valid?: false,
       warnings: term()
     }}

Takes a file path to a cssex or css file and parses it into a final CSS representation returning either:

{:ok, %CSSEx.Parser{}, final_binary}
{:error, %CSSEx.Parser{}}

Additionally a %CSSEx.Parser{} struct with prefilled details can be passed as the first argument in which case the parser will use it as its configuration. You can also pass a file path as the last argument and instead of returning the final binary on the :ok tuple it will write the css directly into that file path and return an empty list instead of the final binary

Link to this function

parse_file(data, base_path, file_path)

View Source

Specs

parse_file(
  %CSSEx.Parser{
    answer_to: term(),
    assigns: term(),
    base_path: term(),
    charset: term(),
    column: term(),
    current_add_var: term(),
    current_assign: term(),
    current_chain: term(),
    current_function: term(),
    current_key: term(),
    current_reg: term(),
    current_scope: term(),
    current_value: term(),
    current_var: term(),
    dependencies: term(),
    error: term(),
    ets: term(),
    ets_fontface: term(),
    ets_keyframes: term(),
    expandables: term(),
    expandables_order_map: term(),
    file: term(),
    file_list: term(),
    first_rule: term(),
    font_face: term(),
    font_face_count: term(),
    functions: term(),
    imports: term(),
    keyframes_order_map: term(),
    level: term(),
    line: term(),
    local_assigns: term(),
    local_scope: term(),
    media: term(),
    media_parent: term(),
    no_count: term(),
    order_map: term(),
    page: term(),
    page_parent: term(),
    pass: term(),
    prefix: term(),
    scope: term(),
    search_acc: term(),
    source_pid: term(),
    split_chain: term(),
    supports: term(),
    supports_parent: term(),
    to_file: term(),
    valid?: term(),
    warnings: term()
  }
  | String.t(),
  String.t(),
  String.t()
) ::
  {:ok,
   %CSSEx.Parser{
     answer_to: term(),
     assigns: term(),
     base_path: term(),
     charset: term(),
     column: term(),
     current_add_var: term(),
     current_assign: term(),
     current_chain: term(),
     current_function: term(),
     current_key: term(),
     current_reg: term(),
     current_scope: term(),
     current_value: term(),
     current_var: term(),
     dependencies: term(),
     error: term(),
     ets: term(),
     ets_fontface: term(),
     ets_keyframes: term(),
     expandables: term(),
     expandables_order_map: term(),
     file: term(),
     file_list: term(),
     first_rule: term(),
     font_face: term(),
     font_face_count: term(),
     functions: term(),
     imports: term(),
     keyframes_order_map: term(),
     level: term(),
     line: term(),
     local_assigns: term(),
     local_scope: term(),
     media: term(),
     media_parent: term(),
     no_count: term(),
     order_map: term(),
     page: term(),
     page_parent: term(),
     pass: term(),
     prefix: term(),
     scope: term(),
     search_acc: term(),
     source_pid: term(),
     split_chain: term(),
     supports: term(),
     supports_parent: term(),
     to_file: term(),
     valid?: term(),
     warnings: term()
   }, String.t() | []}
  | {:error,
     %CSSEx.Parser{
       answer_to: term(),
       assigns: term(),
       base_path: term(),
       charset: term(),
       column: term(),
       current_add_var: term(),
       current_assign: term(),
       current_chain: term(),
       current_function: term(),
       current_key: term(),
       current_reg: term(),
       current_scope: term(),
       current_value: term(),
       current_var: term(),
       dependencies: term(),
       error: String.t(),
       ets: term(),
       ets_fontface: term(),
       ets_keyframes: term(),
       expandables: term(),
       expandables_order_map: term(),
       file: term(),
       file_list: term(),
       first_rule: term(),
       font_face: term(),
       font_face_count: term(),
       functions: term(),
       imports: term(),
       keyframes_order_map: term(),
       level: term(),
       line: term(),
       local_assigns: term(),
       local_scope: term(),
       media: term(),
       media_parent: term(),
       no_count: term(),
       order_map: term(),
       page: term(),
       page_parent: term(),
       pass: term(),
       prefix: term(),
       scope: term(),
       search_acc: term(),
       source_pid: term(),
       split_chain: term(),
       supports: term(),
       supports_parent: term(),
       to_file: term(),
       valid?: false,
       warnings: term()
     }}
Link to this function

parse_file(data, base_path, file_path, parse_to_file)

View Source

Specs

parse_file(
  %CSSEx.Parser{
    answer_to: term(),
    assigns: term(),
    base_path: term(),
    charset: term(),
    column: term(),
    current_add_var: term(),
    current_assign: term(),
    current_chain: term(),
    current_function: term(),
    current_key: term(),
    current_reg: term(),
    current_scope: term(),
    current_value: term(),
    current_var: term(),
    dependencies: term(),
    error: term(),
    ets: term(),
    ets_fontface: term(),
    ets_keyframes: term(),
    expandables: term(),
    expandables_order_map: term(),
    file: term(),
    file_list: term(),
    first_rule: term(),
    font_face: term(),
    font_face_count: term(),
    functions: term(),
    imports: term(),
    keyframes_order_map: term(),
    level: term(),
    line: term(),
    local_assigns: term(),
    local_scope: term(),
    media: term(),
    media_parent: term(),
    no_count: term(),
    order_map: term(),
    page: term(),
    page_parent: term(),
    pass: term(),
    prefix: term(),
    scope: term(),
    search_acc: term(),
    source_pid: term(),
    split_chain: term(),
    supports: term(),
    supports_parent: term(),
    to_file: term(),
    valid?: term(),
    warnings: term()
  }
  | nil,
  path :: String.t(),
  file_path :: String.t(),
  output_path :: String.t() | nil
) ::
  {:ok,
   %CSSEx.Parser{
     answer_to: term(),
     assigns: term(),
     base_path: term(),
     charset: term(),
     column: term(),
     current_add_var: term(),
     current_assign: term(),
     current_chain: term(),
     current_function: term(),
     current_key: term(),
     current_reg: term(),
     current_scope: term(),
     current_value: term(),
     current_var: term(),
     dependencies: term(),
     error: term(),
     ets: term(),
     ets_fontface: term(),
     ets_keyframes: term(),
     expandables: term(),
     expandables_order_map: term(),
     file: term(),
     file_list: term(),
     first_rule: term(),
     font_face: term(),
     font_face_count: term(),
     functions: term(),
     imports: term(),
     keyframes_order_map: term(),
     level: term(),
     line: term(),
     local_assigns: term(),
     local_scope: term(),
     media: term(),
     media_parent: term(),
     no_count: term(),
     order_map: term(),
     page: term(),
     page_parent: term(),
     pass: term(),
     prefix: term(),
     scope: term(),
     search_acc: term(),
     source_pid: term(),
     split_chain: term(),
     supports: term(),
     supports_parent: term(),
     to_file: term(),
     valid?: term(),
     warnings: term()
   }, String.t() | []}
  | {:error,
     %CSSEx.Parser{
       answer_to: term(),
       assigns: term(),
       base_path: term(),
       charset: term(),
       column: term(),
       current_add_var: term(),
       current_assign: term(),
       current_chain: term(),
       current_function: term(),
       current_key: term(),
       current_reg: term(),
       current_scope: term(),
       current_value: term(),
       current_var: term(),
       dependencies: term(),
       error: String.t(),
       ets: term(),
       ets_fontface: term(),
       ets_keyframes: term(),
       expandables: term(),
       expandables_order_map: term(),
       file: term(),
       file_list: term(),
       first_rule: term(),
       font_face: term(),
       font_face_count: term(),
       functions: term(),
       imports: term(),
       keyframes_order_map: term(),
       level: term(),
       line: term(),
       local_assigns: term(),
       local_scope: term(),
       media: term(),
       media_parent: term(),
       no_count: term(),
       order_map: term(),
       page: term(),
       page_parent: term(),
       pass: term(),
       prefix: term(),
       scope: term(),
       search_acc: term(),
       source_pid: term(),
       split_chain: term(),
       supports: term(),
       supports_parent: term(),
       to_file: term(),
       valid?: false,
       warnings: term()
     }}