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

@ -2,6 +2,7 @@ defmodule Outlook.InternalTree do
alias Outlook.InternalTree.{Html,Modifiers,RawInternalBasic,InternalTree,Translation}
alias Outlook.HtmlPreparations.HtmlPreparation
alias Outlook.{Hyphenation, Translations}
def render_html(tree) do
tree
@ -55,11 +56,24 @@ defmodule Outlook.InternalTree do
Translation.render_translation(tree, translation)
end
def legacy_export(tree, translation) do
content= Translation.render_translation(tree, translation)
def render_public_content(tree, translation, language) do
Translation.render_translation(tree, translation)
|> Html.render_doc()
|> Hyphenation.hyphenate(language)
end
def legacy_export(translation_id) do
translation = Translations.get_translation!(translation_id)
content= Translation.render_translation(translation.article.content, translation.content)
|> garnish(%{tunits: %{class: "ttrans", "data-ttrans-status": fn n -> Map.get(n, :status) end}})
|> Html.render_doc
|> Hyphenation.hyphenate(translation.language)
IO.puts "writing export.html to #{File.cwd!}"
File.write("export.html", content)
end
def get_tunit_ids(tree) do
InternalTree.collect_tunit_ids(tree)
# |> List.flatten()
end
end