File: shell_lexer.ex

package info (click to toggle)
elixir-ex-doc 0.35.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,784 kB
  • sloc: javascript: 2,848; makefile: 15; xml: 12; sh: 5
file content (43 lines) | stat: -rw-r--r-- 825 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
defmodule ExDoc.ShellLexer do
  # Makeup lexer for sh, bash, etc commands.
  # The only thing it does is making the `$ ` prompt not selectable.
  @moduledoc false

  @behaviour Makeup.Lexer

  @impl true
  def lex(text, _opts) do
    text
    |> String.split("\n")
    |> Enum.flat_map(fn
      "$ " <> rest ->
        [
          {:generic_prompt, %{selectable: false}, "$ "},
          {:text, %{}, rest <> "\n"}
        ]

      text ->
        [{:text, %{}, text <> "\n"}]
    end)
  end

  @impl true
  def match_groups(_arg0, _arg1) do
    raise "not implemented yet"
  end

  @impl true
  def postprocess(_arg0, _arg1) do
    raise "not implemented yet"
  end

  @impl true
  def root(_arg0) do
    raise "not implemented yet"
  end

  @impl true
  def root_element(_arg0) do
    raise "not implemented yet"
  end
end