Skip to content

Commit

Permalink
Run mix.format on codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowtie committed Jan 22, 2018
1 parent c98f6a3 commit 34fee45
Show file tree
Hide file tree
Showing 8 changed files with 789 additions and 513 deletions.
170 changes: 97 additions & 73 deletions lib/unicodedata.ex

Large diffs are not rendered by default.

45 changes: 28 additions & 17 deletions lib/unicodedata/bidi.ex
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
defmodule UnicodeData.Bidi do
@moduledoc false
@external_resource bidic_path = Path.join([__DIR__, "DerivedBidiClass.txt"])
lines = File.stream!(bidic_path, [], :line)
|> Stream.filter(&String.match?(&1, ~r/^[0-9A-F]+/))
lines =
File.stream!(bidic_path, [], :line)
|> Stream.filter(&String.match?(&1, ~r/^[0-9A-F]+/))

for line <- lines do
[r, s, _] = String.split(line, ~r/[\#;]/)
r = String.trim(r)
|> String.split("..")
|> Enum.map(&Integer.parse(&1, 16))
|> Enum.map(fn {x, _} -> x end)

r =
String.trim(r)
|> String.split("..")
|> Enum.map(&Integer.parse(&1, 16))
|> Enum.map(fn {x, _} -> x end)

s = String.trim(s)

case r do
[x] ->
def bidi_class(unquote(x)) do
unquote(s)
end

[a, b] ->
def bidi_class(n) when n in unquote(a)..unquote(b) do
unquote(s)
Expand All @@ -29,35 +36,39 @@ defmodule UnicodeData.Bidi do

# Bidi mirroring
@external_resource bidim_path = Path.join([__DIR__, "BidiMirroring.txt"])
lines = File.stream!(bidim_path, [], :line)
|> Stream.filter(&String.match?(&1, ~r/^[0-9A-F]+/))
lines =
File.stream!(bidim_path, [], :line)
|> Stream.filter(&String.match?(&1, ~r/^[0-9A-F]+/))

for line <- lines do
[r, s, _] = String.split(line, ~r/[\#;]/)
{orig, _} = r |> String.trim |> Integer.parse(16)
{mirrored, _} = s |> String.trim |> Integer.parse(16)
{orig, _} = r |> String.trim() |> Integer.parse(16)
{mirrored, _} = s |> String.trim() |> Integer.parse(16)
def mirrored?(unquote(orig)), do: true

def mirror_glyph(unquote(orig)) do
unquote(mirrored)
end
end

def mirrored?(_n), do: false
def mirror_glyph(_n), do: nil

# Bidi brackets
@external_resource bidib_path = Path.join([__DIR__, "BidiBrackets.txt"])
lines = File.stream!(bidib_path, [], :line)
|> Stream.filter(&String.match?(&1, ~r/^[0-9A-F]+/))
lines =
File.stream!(bidib_path, [], :line)
|> Stream.filter(&String.match?(&1, ~r/^[0-9A-F]+/))

for line <- lines do
[r, s, t, _] = String.split(line, ~r/[\#;]/)
{orig, _} = r |> String.trim |> Integer.parse(16)
{paired, _} = s |> String.trim |> Integer.parse(16)
{orig, _} = r |> String.trim() |> Integer.parse(16)
{paired, _} = s |> String.trim() |> Integer.parse(16)
t = String.trim(t)
def paired_bracket_type(unquote(orig)), do: unquote(t)
def paired_bracket(unquote(orig)), do: unquote(paired)
end

def paired_bracket_type(_n), do: "n"
def paired_bracket(_n), do: nil


end

Loading

0 comments on commit 34fee45

Please sign in to comment.