File: utils.ex

package info (click to toggle)
elixir-makeup 1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 384 kB
  • sloc: javascript: 24; makefile: 9
file content (115 lines) | stat: -rw-r--r-- 2,911 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
defmodule Makeup.Token.Utils do
  @moduledoc false
  alias Makeup.Token.Utils.Hierarchy

  @hierarchy [
    {:text, nil},
    {:whitespace, "w"},
    {:escape, "esc"},
    {:error, "err"},
    {:other, "x"},

    {:comment, "c", [
      {:comment_hashbang, "ch"},
      {:comment_multiline, "cm"},
      {:comment_preproc, "cp", [
        {:comment_preproc_file, "cpf"}]},
      {:comment_single, "c1"},
      {:comment_special, "cs"}]},

    {:keyword, "k", [
      {:keyword_constant, "kc"},
      {:keyword_declaration, "kd"},
      {:keyword_namespace, "kn"},
      {:keyword_pseudo, "kp"},
      {:keyword_reserved, "kr"},
      {:keyword_type, "kt"}]},

    {:literal, "l", [
      {:literal_date, "ld"}]},

    {:name, "n", [
      {:name_attribute, "na"},
      {:name_builtin, "nb", [
        {:name_builtin_pseudo, "bp"}]},
      {:name_class, "nc"},
      {:name_constant, "no"},
      {:name_decorator, "nd"},
      {:name_entity, "ni"},
      {:name_exception, "ne"},
      {:name_function, "nf", [
        {:name_function_magic, "fm"}]},
      {:name_property, "py"},
      {:name_label, "nl"},
      {:name_namespace, "nn"},
      {:name_other, "nx"},
      {:name_tag, "nt"},
      {:name_variable, "nv", [
        {:name_variable_class, "vc"},
        {:name_variable_global, "vg"},
        {:name_variable_instance, "vi"},
        {:name_variable_magic, "vm"}]}]},

    {:number, "m", [
      {:number_bin, "mb"},
      {:number_float, "mf"},
      {:number_hex, "mh"},
      {:number_integer, "mi", [
        {:number_integer_long, "il"}]},
      {:number_oct, "mo"}]},

    {:string, "s", [
      {:string_affix, "sa"},
      {:string_backtick, "sb"},
      {:string_char, "sc"},
      {:string_delimiter, "dl"},
      {:string_doc, "sd"},
      {:string_double, "s2"},
      {:string_escape, "se"},
      {:string_heredoc, "sh"},
      {:string_interpol, "si"},
      {:string_other, "sx"},
      {:string_regex, "sr"},
      {:string_sigil, "sx"},
      {:string_single, "s1"},
      {:string_symbol, "ss"}]},

    {:operator, "o", [
      {:operator_word, "ow"}]},

    {:punctuation, "p"},

    {:generic, "g", [
      {:generic_deleted, "gd"},
      {:generic_emph, "ge"},
      {:generic_error, "gr"},
      {:generic_heading, "gh"},
      {:generic_inserted, "gi"},
      {:generic_prompt, "gp"},
      {:generic_output, "go"},
      {:generic_strong, "gs"},
      {:generic_subheading, "gu"},
      {:generic_traceback, "gt"}]}
  ]


  @precedence Hierarchy.hierarchy_to_precedence(@hierarchy)
  @token_to_class_map Hierarchy.style_to_class_map(@hierarchy)
  @standard_token_types Map.keys(@token_to_class_map)

  def precedence do
    @precedence
  end

  def token_to_class_map do
    @token_to_class_map
  end

  def standard_token_types do
    @standard_token_types
  end

  def css_class_for_token_type(token_type) do
    Map.get(@token_to_class_map, token_type, nil)
  end
end