Skip to content

Commit

Permalink
Support tabs and remove \f as whitespace (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshprice authored Jul 18, 2024
1 parent e3be8d2 commit d83f23f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/makeup/lexers/elixir_lexer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Makeup.Lexers.ElixirLexer do
# TODO: check we're following this convention
# NOTE: if Elixir had a good static type system it would help us do the right thing here.

whitespace = ascii_string([?\r, ?\s, ?\n, ?\f], min: 1) |> token(:whitespace)
whitespace = ascii_string([?\r, ?\s, ?\n, ?\t], min: 1) |> token(:whitespace)

newlines =
optional(ascii_string([?\s, ?\t, ?\r], min: 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ defmodule ElixirLexerTokenizerTestSnippet do
use ExUnit.Case, async: false
import Makeup.Lexers.ElixirLexer.Testing, only: [lex: 1]

test "?\\f is recognized as whitespace character" do
assert lex("\f") == [{:whitespace, %{}, "\f"}]
test "whitespace" do
assert lex(" ") == [{:whitespace, %{}, " "}]
assert lex("\s") == [{:whitespace, %{}, "\s"}]
assert lex("\n") == [{:whitespace, %{}, "\n"}]
assert lex("\t") == [{:whitespace, %{}, "\t"}]
assert lex("\r") == [{:whitespace, %{}, "\r"}]
end

test "builtins" do
Expand Down

0 comments on commit d83f23f

Please sign in to comment.