support source:markdown in RSS feed
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
This commit is contained in:
parent
8e5a88edf7
commit
eed5d7dc76
2 changed files with 30 additions and 0 deletions
|
@ -112,4 +112,30 @@ def escape(html) do
|
||||||
|> html_escape()
|
|> html_escape()
|
||||||
|> safe_to_string()
|
|> safe_to_string()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Encoding newlines, e.g., per XML spec
|
||||||
|
def rss_escape(nil), do: ""
|
||||||
|
def rss_escape(data) when is_binary(data) do
|
||||||
|
data
|
||||||
|
|> rss_escape_string()
|
||||||
|
|> to_string()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp rss_escape_string(""), do: ""
|
||||||
|
defp rss_escape_string(<<"&"::utf8, rest::binary>>), do: rss_escape_entity(rest)
|
||||||
|
defp rss_escape_string(<<"<"::utf8, rest::binary>>), do: ["<" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<">"::utf8, rest::binary>>), do: [">" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<"\""::utf8, rest::binary>>), do: [""" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<"'"::utf8, rest::binary>>), do: ["'" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<"\t"::utf8, rest::binary>>), do: ["	" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<"\n"::utf8, rest::binary>>), do: [" " | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<"\r\n"::utf8, rest::binary>>), do: [" " | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<"\r"::utf8, rest::binary>>), do: [" " | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_string(<<c::utf8, rest::binary>>), do: [c | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_entity(<<"amp;"::utf8, rest::binary>>), do: ["&" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_entity(<<"lt;"::utf8, rest::binary>>), do: ["<" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_entity(<<"gt;"::utf8, rest::binary>>), do: [">" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_entity(<<"quot;"::utf8, rest::binary>>), do: [""" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_entity(<<"apos;"::utf8, rest::binary>>), do: ["'" | rss_escape_string(rest)]
|
||||||
|
defp rss_escape_entity(rest), do: ["&" | rss_escape_string(rest)]
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
<description><%= escape(@data["summary"]) %></description>
|
<description><%= escape(@data["summary"]) %></description>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= if get_in(@data, ["source", "mediaType"]) == "text/markdown" do %>
|
||||||
|
<source:markdown><%= rss_escape(get_in(@data, ["source", "content"])) %></source:markdown>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= if @activity.local do %>
|
<%= if @activity.local do %>
|
||||||
<link><%= @data["id"] %></link>
|
<link><%= @data["id"] %></link>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
Loading…
Reference in a new issue