zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

utils.ex (2911B)


      1 defmodule Makeup.Token.Utils do
      2   @moduledoc false
      3   alias Makeup.Token.Utils.Hierarchy
      4 
      5   @hierarchy [
      6     {:text, nil},
      7     {:whitespace, "w"},
      8     {:escape, "esc"},
      9     {:error, "err"},
     10     {:other, "x"},
     11 
     12     {:comment, "c", [
     13       {:comment_hashbang, "ch"},
     14       {:comment_multiline, "cm"},
     15       {:comment_preproc, "cp", [
     16         {:comment_preproc_file, "cpf"}]},
     17       {:comment_single, "c1"},
     18       {:comment_special, "cs"}]},
     19 
     20     {:keyword, "k", [
     21       {:keyword_constant, "kc"},
     22       {:keyword_declaration, "kd"},
     23       {:keyword_namespace, "kn"},
     24       {:keyword_pseudo, "kp"},
     25       {:keyword_reserved, "kr"},
     26       {:keyword_type, "kt"}]},
     27 
     28     {:literal, "l", [
     29       {:literal_date, "ld"}]},
     30 
     31     {:name, "n", [
     32       {:name_attribute, "na"},
     33       {:name_builtin, "nb", [
     34         {:name_builtin_pseudo, "bp"}]},
     35       {:name_class, "nc"},
     36       {:name_constant, "no"},
     37       {:name_decorator, "nd"},
     38       {:name_entity, "ni"},
     39       {:name_exception, "ne"},
     40       {:name_function, "nf", [
     41         {:name_function_magic, "fm"}]},
     42       {:name_property, "py"},
     43       {:name_label, "nl"},
     44       {:name_namespace, "nn"},
     45       {:name_other, "nx"},
     46       {:name_tag, "nt"},
     47       {:name_variable, "nv", [
     48         {:name_variable_class, "vc"},
     49         {:name_variable_global, "vg"},
     50         {:name_variable_instance, "vi"},
     51         {:name_variable_magic, "vm"}]}]},
     52 
     53     {:number, "m", [
     54       {:number_bin, "mb"},
     55       {:number_float, "mf"},
     56       {:number_hex, "mh"},
     57       {:number_integer, "mi", [
     58         {:number_integer_long, "il"}]},
     59       {:number_oct, "mo"}]},
     60 
     61     {:string, "s", [
     62       {:string_affix, "sa"},
     63       {:string_backtick, "sb"},
     64       {:string_char, "sc"},
     65       {:string_delimiter, "dl"},
     66       {:string_doc, "sd"},
     67       {:string_double, "s2"},
     68       {:string_escape, "se"},
     69       {:string_heredoc, "sh"},
     70       {:string_interpol, "si"},
     71       {:string_other, "sx"},
     72       {:string_regex, "sr"},
     73       {:string_sigil, "sx"},
     74       {:string_single, "s1"},
     75       {:string_symbol, "ss"}]},
     76 
     77     {:operator, "o", [
     78       {:operator_word, "ow"}]},
     79 
     80     {:punctuation, "p"},
     81 
     82     {:generic, "g", [
     83       {:generic_deleted, "gd"},
     84       {:generic_emph, "ge"},
     85       {:generic_error, "gr"},
     86       {:generic_heading, "gh"},
     87       {:generic_inserted, "gi"},
     88       {:generic_prompt, "gp"},
     89       {:generic_output, "go"},
     90       {:generic_strong, "gs"},
     91       {:generic_subheading, "gu"},
     92       {:generic_traceback, "gt"}]}
     93   ]
     94 
     95 
     96   @precedence Hierarchy.hierarchy_to_precedence(@hierarchy)
     97   @token_to_class_map Hierarchy.style_to_class_map(@hierarchy)
     98   @standard_token_types Map.keys(@token_to_class_map)
     99 
    100   def precedence do
    101     @precedence
    102   end
    103 
    104   def token_to_class_map do
    105     @token_to_class_map
    106   end
    107 
    108   def standard_token_types do
    109     @standard_token_types
    110   end
    111 
    112   def css_class_for_token_type(token_type) do
    113     Map.get(@token_to_class_map, token_type, nil)
    114   end
    115 end