浏览代码

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

pull/5/head
Christian Kruse 3 年前
父节点
当前提交
b9754e1875
共有 3 个文件被更改,包括 7 次插入7 次删除
  1. +3
    -3
      lib/items.ex
  2. +1
    -1
      lib/microformats2.ex
  3. +3
    -3
      lib/rels.ex

+ 3
- 3
lib/items.ex 查看文件

@ -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 查看文件

@ -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 查看文件

@ -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,


正在加载...
取消
保存