Browse Source

ref: use String.trim/1 instead of String.strip/1

tags/microformats2-0.1.0
Christian Kruse 3 years ago
parent
commit
b9754e1875
3 changed files with 7 additions and 7 deletions
  1. +3
    -3
      lib/items.ex
  2. +1
    -1
      lib/microformats2.ex
  3. +3
    -3
      lib/rels.ex

+ 3
- 3
lib/items.ex View File

@@ -56,7 +56,7 @@ defmodule Microformats2.Items do
elem == "img" and not Microformats2.blank?(alt) ->
alt
true ->
text_content(child) |> String.strip
text_content(child) |> String.trim
end
end

@@ -84,7 +84,7 @@ defmodule Microformats2.Items do
Enum.member?(["data", "input"], elem) and not Microformats2.blank?(value) ->
value
true ->
text_content(child) |> String.strip
text_content(child) |> String.trim
end |> Microformats2.abs_uri(url, doc)
end

@@ -101,7 +101,7 @@ defmodule Microformats2.Items do
Enum.member?(["data", "input"], elem) and not Microformats2.blank?(value) ->
value |> List.first
true ->
text_content(child) |> String.strip
text_content(child) |> String.trim
end
end



+ 1
- 1
lib/microformats2.ex View File

@@ -33,7 +33,7 @@ defmodule Microformats2 do
def blank?(_), do: false

def stripped_or_nil(nil), do: nil
def stripped_or_nil(val), do: String.strip(val)
def stripped_or_nil(val), do: String.trim(val)

def is_rootlevel?(node) when is_tuple(node) do
attr_list(node, "class") |>


+ 3
- 3
lib/rels.ex View File

@@ -5,7 +5,7 @@ defmodule Microformats2.Rels do
rel = Floki.attribute(element, "rel") |> List.first
href = Floki.attribute(element, "href") |> List.first

String.strip(to_string(rel)) != "" and String.strip(to_string(href)) != ""
String.trim(to_string(rel)) != "" and String.trim(to_string(href)) != ""
end) |>
Enum.reduce(%{rels: %{}, rel_urls: %{}}, fn(element, acc) ->
rel = Microformats2.attr_list(element, "rel")
@@ -47,7 +47,7 @@ defmodule Microformats2.Rels do
defp save_text(map, element, url) do
text = Floki.text(element)

if String.strip(to_string(text)) == "" or map[:rel_urls][url][:text] != nil do
if String.trim(to_string(text)) == "" or map[:rel_urls][url][:text] != nil do
map
else
Map.put(map, :rel_urls,
@@ -62,7 +62,7 @@ defmodule Microformats2.Rels do
fn(att, nmap) ->
val = Floki.attribute(element, att) |> List.first

if String.strip(to_string(val)) == "" or nmap[:rel_urls][url][String.to_atom(att)] != nil do
if String.trim(to_string(val)) == "" or nmap[:rel_urls][url][String.to_atom(att)] != nil do
nmap
else
Map.put(nmap, :rel_urls,


Loading…
Cancel
Save