Add hyphenation and a generalized render_public_content function

This commit is contained in:
Thelonius Kort
2023-01-26 21:48:50 +01:00
parent e8e7f877e7
commit 38b3f0c272
3 changed files with 53 additions and 4 deletions

View File

@ -0,0 +1,31 @@
defmodule Outlook.Hyphenation do
def hyphenate(html, lang) do
form = get_multipart_form(
[
{"api-token", System.get_env("HYPH_API_TOKEN")},
{"hyph[lang]", String.downcase(lang)},
{"hyph[text]", html},
]
)
response_raw = HTTPoison.request!(
:post,
System.get_env("HYPH_URL"),
form,
get_multipart_headers()
)
response_raw.body
end
defp get_multipart_form fields do
{:multipart, fields}
end
defp get_multipart_headers() do
[
"Content-Type": "multipart/form-data",
"Transfer-Encoding": "chunked",
]
end
end