forked from AkkomaGang/akkoma
better formatting for titles
This commit is contained in:
parent
8b488899aa
commit
b0532e136b
|
@ -286,7 +286,7 @@ config :pleroma, :feed,
|
||||||
max_length: 100,
|
max_length: 100,
|
||||||
omission: "...",
|
omission: "...",
|
||||||
# New method to extract title
|
# New method to extract title
|
||||||
parse_source: true
|
parse_source: false
|
||||||
}
|
}
|
||||||
|
|
||||||
config :pleroma, :markup,
|
config :pleroma, :markup,
|
||||||
|
|
|
@ -2919,6 +2919,7 @@ config :pleroma, :config_description, [
|
||||||
%{
|
%{
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :feed,
|
key: :feed,
|
||||||
|
label: "RSS Feeds",
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Configure feed rendering",
|
description: "Configure feed rendering",
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -156,10 +156,13 @@ defmodule Pleroma.Formatter do
|
||||||
|
|
||||||
length_with_omission = max_length - String.length(omission)
|
length_with_omission = max_length - String.length(omission)
|
||||||
|
|
||||||
if length_with_omission <= 0 do
|
cond do
|
||||||
String.slice(text, 0, max_length)
|
String.length(text) <= max_length ->
|
||||||
else
|
text
|
||||||
String.slice(text, 0, length_with_omission) <> omission
|
length_with_omission > 0 ->
|
||||||
|
String.slice(text, 0, length_with_omission) <> omission
|
||||||
|
true ->
|
||||||
|
String.slice(text, 0, max_length)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ defmodule Pleroma.Web.Feed.FeedView do
|
||||||
split_content(content, content_type, opts) |> elem(0)
|
split_content(content, content_type, opts) |> elem(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: scrub_html should replace <p> with " "
|
||||||
def activity_title(%{"content" => content}, opts) do
|
def activity_title(%{"content" => content}, opts) do
|
||||||
content
|
content
|
||||||
|> Pleroma.Web.Metadata.Utils.scrub_html()
|
|> Pleroma.Web.Metadata.Utils.scrub_html()
|
||||||
|
|
|
@ -42,8 +42,12 @@ defmodule Pleroma.Web.Metadata.Utils do
|
||||||
content
|
content
|
||||||
# html content comes from DB already encoded, decode first and scrub after
|
# html content comes from DB already encoded, decode first and scrub after
|
||||||
|> HtmlEntities.decode()
|
|> HtmlEntities.decode()
|
||||||
|> String.replace(~r/<br\s?\/?>/, " ")
|
|> String.replace(~r/<(br|p)[^>]*>/, "\\0 ")
|
||||||
|
|> String.replace(~r/<\/p\s*\/?>/, " \\0")
|
||||||
|> HTML.strip_tags()
|
|> HTML.strip_tags()
|
||||||
|
# strip_tags will convert to U+00A0, adding /u will match these to " "
|
||||||
|
|> String.replace(~r/\s+/u, " ")
|
||||||
|
|> String.trim()
|
||||||
end
|
end
|
||||||
|
|
||||||
def scrub_html(content), do: content
|
def scrub_html(content), do: content
|
||||||
|
|
Loading…
Reference in a new issue