Allow authoring MFM
This commit is contained in:
parent
3f06ccc9e3
commit
4fb2251221
4 changed files with 16 additions and 5 deletions
|
@ -222,7 +222,8 @@
|
||||||
"text/plain",
|
"text/plain",
|
||||||
"text/html",
|
"text/html",
|
||||||
"text/markdown",
|
"text/markdown",
|
||||||
"text/bbcode"
|
"text/bbcode",
|
||||||
|
"text/x.misskeymarkdown"
|
||||||
],
|
],
|
||||||
staff_transparency: [],
|
staff_transparency: [],
|
||||||
autofollowed_nicknames: [],
|
autofollowed_nicknames: [],
|
||||||
|
|
|
@ -165,7 +165,7 @@ def maybe_quote(name) when is_binary(name) do
|
||||||
|
|
||||||
def maybe_quote(name), do: name
|
def maybe_quote(name), do: name
|
||||||
|
|
||||||
def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => []}), do: nil
|
def emoji_url(%{"type" => "EmojiReact", "content" => _, "tag" => []}), do: nil
|
||||||
|
|
||||||
def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => tags}) do
|
def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => tags}) do
|
||||||
tag =
|
tag =
|
||||||
|
|
|
@ -213,13 +213,14 @@ defp object(draft) do
|
||||||
end
|
end
|
||||||
|
|
||||||
emoji = Map.merge(emoji, summary_emoji)
|
emoji = Map.merge(emoji, summary_emoji)
|
||||||
|
|
||||||
{:ok, note_data, _meta} = Builder.note(draft)
|
{:ok, note_data, _meta} = Builder.note(draft)
|
||||||
|
|
||||||
object =
|
object =
|
||||||
note_data
|
note_data
|
||||||
|> Map.put("emoji", emoji)
|
|> Map.put("emoji", emoji)
|
||||||
|> Map.put("source", draft.status)
|
|> Map.put("source", %{
|
||||||
|
"content" => draft.status,
|
||||||
|
"mediaType" => draft.params[:content_type]
|
||||||
|
})
|
||||||
|> Map.put("generator", draft.params[:generator])
|
|> Map.put("generator", draft.params[:generator])
|
||||||
|
|
||||||
%__MODULE__{draft | object: object}
|
%__MODULE__{draft | object: object}
|
||||||
|
|
|
@ -291,6 +291,15 @@ def format_input(text, "text/markdown", options) do
|
||||||
|> Formatter.html_escape("text/html")
|
|> Formatter.html_escape("text/html")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_input(text, "text/x.misskeymarkdown", options) do
|
||||||
|
text
|
||||||
|
|> Formatter.html_escape("text/plain")
|
||||||
|
|> Formatter.linkify(options)
|
||||||
|
|> (fn {text, mentions, tags} ->
|
||||||
|
{String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
|
||||||
|
end).()
|
||||||
|
end
|
||||||
|
|
||||||
def format_naive_asctime(date) do
|
def format_naive_asctime(date) do
|
||||||
date |> DateTime.from_naive!("Etc/UTC") |> format_asctime
|
date |> DateTime.from_naive!("Etc/UTC") |> format_asctime
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue