From 20dc3fb32ad106726900e609c1f3519d54e1b464 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <arnaud.levy@noesya.coop>
Date: Thu, 15 Feb 2024 12:29:41 +0100
Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20automatique=20de=20la=20com?=
 =?UTF-8?q?position=20typographique=20avec=20Orthotypo=20(#1344)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* refactor, no orthotypo yet

* orthotypo

* bundle

* fix

* simpler

* fix

* gem

* Fix

* gemfile

* schema

---------

Co-authored-by: Sébastien Gaya <sebastien.gaya@gmail.com>
Co-authored-by: pabois <pierreandre.boissinot@noesya.coop>
---
 Gemfile                                       |   1 +
 Gemfile.lock                                  | 219 +++++++++---------
 app/helpers/admin/application_helper.rb       |  22 +-
 app/services/static/code.rb                   |  12 +
 app/services/static/default.rb                |  35 +++
 app/services/static/html.rb                   |  16 ++
 app/services/static/text.rb                   |  14 ++
 .../featured_image/_static.html.erb           |   4 +-
 .../application/summary/_static.html.erb      |   3 -
 .../blocks/components/code/_static.html.erb   |   4 +-
 .../components/rich_text/_static.html.erb     |   4 +-
 .../blocks/components/string/_static.html.erb |   4 +-
 .../blocks/components/text/_static.html.erb   |   4 +-
 .../blocks/headings/_static.html.erb          |   3 +-
 .../websites/agenda/events/static.html.erb    |   4 +-
 .../websites/pages/static.html.erb            |  10 +-
 .../websites/posts/categories/static.html.erb |   2 +-
 .../websites/posts/static.html.erb            |   4 +-
 .../admin/education/diplomas/static.html.erb  |   3 +-
 .../admin/education/programs/static.html.erb  |   5 +-
 .../admin/education/schools/static.html.erb   |  21 +-
 .../journals/papers/kinds/static.html.erb     |   3 +-
 .../research/journals/papers/static.html.erb  |  22 +-
 .../research/journals/volumes/static.html.erb |   6 +-
 .../research/publications/static.html.erb     |   6 +-
 .../university/organizations/static.html.erb  |   7 +-
 .../admin/university/people/static.html.erb   |   4 +-
 db/schema.rb                                  |   4 +-
 28 files changed, 250 insertions(+), 196 deletions(-)
 create mode 100644 app/services/static/code.rb
 create mode 100644 app/services/static/default.rb
 create mode 100644 app/services/static/html.rb
 create mode 100644 app/services/static/text.rb

diff --git a/Gemfile b/Gemfile
index d5ec91353..46a4a94d2 100644
--- a/Gemfile
+++ b/Gemfile
@@ -56,6 +56,7 @@ gem "mini_magick"
 gem "octokit"
 gem "omniauth-rails_csrf_protection", "~> 1"
 gem "omniauth-saml", "~> 2"
+gem "orthotypo"#, path: '../../noesya/orthotypo'
 gem "pexels", "~> 0"
 gem "pg", "~> 1"
 gem "puma"
diff --git a/Gemfile.lock b/Gemfile.lock
index 3f0d1ac1f..45c63aca2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -28,35 +28,35 @@ GIT
 GEM
   remote: https://rubygems.org/
   specs:
-    actioncable (7.1.3)
-      actionpack (= 7.1.3)
-      activesupport (= 7.1.3)
+    actioncable (7.1.2)
+      actionpack (= 7.1.2)
+      activesupport (= 7.1.2)
       nio4r (~> 2.0)
       websocket-driver (>= 0.6.1)
       zeitwerk (~> 2.6)
-    actionmailbox (7.1.3)
-      actionpack (= 7.1.3)
-      activejob (= 7.1.3)
-      activerecord (= 7.1.3)
-      activestorage (= 7.1.3)
-      activesupport (= 7.1.3)
+    actionmailbox (7.1.2)
+      actionpack (= 7.1.2)
+      activejob (= 7.1.2)
+      activerecord (= 7.1.2)
+      activestorage (= 7.1.2)
+      activesupport (= 7.1.2)
       mail (>= 2.7.1)
       net-imap
       net-pop
       net-smtp
-    actionmailer (7.1.3)
-      actionpack (= 7.1.3)
-      actionview (= 7.1.3)
-      activejob (= 7.1.3)
-      activesupport (= 7.1.3)
+    actionmailer (7.1.2)
+      actionpack (= 7.1.2)
+      actionview (= 7.1.2)
+      activejob (= 7.1.2)
+      activesupport (= 7.1.2)
       mail (~> 2.5, >= 2.5.4)
       net-imap
       net-pop
       net-smtp
       rails-dom-testing (~> 2.2)
-    actionpack (7.1.3)
-      actionview (= 7.1.3)
-      activesupport (= 7.1.3)
+    actionpack (7.1.2)
+      actionview (= 7.1.2)
+      activesupport (= 7.1.2)
       nokogiri (>= 1.8.5)
       racc
       rack (>= 2.2.4)
@@ -64,15 +64,15 @@ GEM
       rack-test (>= 0.6.3)
       rails-dom-testing (~> 2.2)
       rails-html-sanitizer (~> 1.6)
-    actiontext (7.1.3)
-      actionpack (= 7.1.3)
-      activerecord (= 7.1.3)
-      activestorage (= 7.1.3)
-      activesupport (= 7.1.3)
+    actiontext (7.1.2)
+      actionpack (= 7.1.2)
+      activerecord (= 7.1.2)
+      activestorage (= 7.1.2)
+      activesupport (= 7.1.2)
       globalid (>= 0.6.0)
       nokogiri (>= 1.8.5)
-    actionview (7.1.3)
-      activesupport (= 7.1.3)
+    actionview (7.1.2)
+      activesupport (= 7.1.2)
       builder (~> 3.1)
       erubi (~> 1.11)
       rails-dom-testing (~> 2.2)
@@ -82,25 +82,25 @@ GEM
       activemodel (>= 5.2.0)
       activestorage (>= 5.2.0)
       activesupport (>= 5.2.0)
-    activejob (7.1.3)
-      activesupport (= 7.1.3)
+    activejob (7.1.2)
+      activesupport (= 7.1.2)
       globalid (>= 0.3.6)
-    activemodel (7.1.3)
-      activesupport (= 7.1.3)
-    activerecord (7.1.3)
-      activemodel (= 7.1.3)
-      activesupport (= 7.1.3)
+    activemodel (7.1.2)
+      activesupport (= 7.1.2)
+    activerecord (7.1.2)
+      activemodel (= 7.1.2)
+      activesupport (= 7.1.2)
       timeout (>= 0.4.0)
-    activestorage (7.1.3)
-      actionpack (= 7.1.3)
-      activejob (= 7.1.3)
-      activerecord (= 7.1.3)
-      activesupport (= 7.1.3)
+    activestorage (7.1.2)
+      actionpack (= 7.1.2)
+      activejob (= 7.1.2)
+      activerecord (= 7.1.2)
+      activesupport (= 7.1.2)
       marcel (~> 1.0)
-    activestorage-scaleway-service (1.1.0)
+    activestorage-scaleway-service (1.0.1)
       activestorage
       aws-sdk-s3
-    activesupport (7.1.3)
+    activesupport (7.1.2)
       base64
       bigdecimal
       concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -123,26 +123,26 @@ GEM
     autoprefixer-rails (10.4.16.0)
       execjs (~> 2)
     aws-eventstream (1.3.0)
-    aws-partitions (1.887.0)
-    aws-sdk-core (3.191.0)
+    aws-partitions (1.875.0)
+    aws-sdk-core (3.190.1)
       aws-eventstream (~> 1, >= 1.3.0)
       aws-partitions (~> 1, >= 1.651.0)
       aws-sigv4 (~> 1.8)
       jmespath (~> 1, >= 1.6.1)
-    aws-sdk-kms (1.77.0)
-      aws-sdk-core (~> 3, >= 3.191.0)
+    aws-sdk-kms (1.75.0)
+      aws-sdk-core (~> 3, >= 3.188.0)
       aws-sigv4 (~> 1.1)
-    aws-sdk-s3 (1.143.0)
-      aws-sdk-core (~> 3, >= 3.191.0)
+    aws-sdk-s3 (1.142.0)
+      aws-sdk-core (~> 3, >= 3.189.0)
       aws-sdk-kms (~> 1)
       aws-sigv4 (~> 1.8)
     aws-sigv4 (1.8.0)
       aws-eventstream (~> 1, >= 1.0.2)
     base64 (0.2.0)
     bcrypt (3.1.20)
-    bigdecimal (3.1.6)
+    bigdecimal (3.1.5)
     bindex (0.8.1)
-    bootsnap (1.18.3)
+    bootsnap (1.17.0)
       msgpack (~> 1.2)
     bootstrap (5.3.2)
       autoprefixer-rails (>= 9.1.0)
@@ -152,16 +152,16 @@ GEM
       rails (>= 3.1)
     breadcrumbs_on_rails (4.1.0)
       railties (>= 5.0)
-    bugsnag (6.26.3)
+    bugsnag (6.26.0)
       concurrent-ruby (~> 1.0)
     builder (3.2.4)
     byebug (11.1.3)
     cancancan (3.3.0)
-    capybara (3.40.0)
+    capybara (3.39.2)
       addressable
       matrix
       mini_mime (>= 0.1.3)
-      nokogiri (~> 1.11)
+      nokogiri (~> 1.8)
       rack (>= 1.6.0)
       rack-test (>= 0.6.3)
       regexp_parser (>= 1.5, < 3.0)
@@ -180,14 +180,13 @@ GEM
       citeproc (~> 1.0, >= 1.0.9)
       csl (~> 2.0)
     cocoon (1.2.15)
-    concurrent-ruby (1.2.3)
+    concurrent-ruby (1.2.2)
     connection_pool (2.4.1)
     countries (5.7.1)
       unaccent (~> 0.3)
     country_select (8.0.3)
       countries (~> 5.0)
-    crack (0.4.6)
-      bigdecimal
+    crack (0.4.5)
       rexml
     crass (1.0.6)
     csl (2.0.0)
@@ -222,7 +221,7 @@ GEM
     devise-i18n (1.12.0)
       devise (>= 4.9.0)
     docile (1.4.0)
-    domain_name (0.6.20240107)
+    domain_name (0.6.20231109)
     drb (2.2.0)
       ruby2_keywords
     encryptor (3.0.0)
@@ -235,8 +234,10 @@ GEM
     faceted_search (3.6.2)
       font-awesome-sass
       rails (>= 5.2.0)
-    faraday (2.9.0)
-      faraday-net_http (>= 2.0, < 3.2)
+    faraday (2.8.1)
+      base64
+      faraday-net_http (>= 2.0, < 3.1)
+      ruby2_keywords (>= 0.0.4)
     faraday-cookie_jar (0.0.7)
       faraday (>= 0.8.0)
       http-cookie (~> 1.0.0)
@@ -247,12 +248,11 @@ GEM
     faraday-gzip (1.0.0)
       faraday (>= 1.0)
       zlib (~> 2.1)
-    faraday-http-cache (2.5.1)
+    faraday-http-cache (2.5.0)
       faraday (>= 0.8)
     faraday-multipart (1.0.4)
       multipart-post (~> 2)
-    faraday-net_http (3.1.0)
-      net-http
+    faraday-net_http (3.0.2)
     faraday-retry (2.2.0)
       faraday (~> 2.0)
     fastimage (2.3.0)
@@ -308,10 +308,10 @@ GEM
     image_processing (1.12.2)
       mini_magick (>= 4.9.5, < 5)
       ruby-vips (>= 2.0.17, < 3)
-    io-console (0.7.2)
-    irb (1.11.1)
+    io-console (0.7.1)
+    irb (1.11.0)
       rdoc
-      reline (>= 0.4.2)
+      reline (>= 0.3.8)
     jbuilder (2.11.5)
       actionview (>= 5.0.0)
       activesupport (>= 5.0.0)
@@ -371,33 +371,32 @@ GEM
       nokogiri (~> 1.13)
     mini_magick (4.12.0)
     mini_mime (1.1.5)
-    minitest (5.22.0)
+    minitest (5.20.0)
     msgpack (1.7.2)
     multi_xml (0.6.0)
     multipart-post (2.3.0)
     mustermann (3.0.0)
       ruby2_keywords (~> 0.0.1)
     mutex_m (0.2.0)
-    namae (1.2.0)
-      racc (~> 1.7)
+    namae (1.1.1)
     nesty (1.0.2)
-    net-http (0.4.1)
+    net-http (0.4.0)
       uri
-    net-imap (0.4.10)
+    net-imap (0.4.9)
       date
       net-protocol
     net-pop (0.1.2)
       net-protocol
     net-protocol (0.2.2)
       timeout
-    net-smtp (0.4.0.1)
+    net-smtp (0.4.0)
       net-protocol
     nio4r (2.7.0)
-    nokogiri (1.16.2-arm64-darwin)
+    nokogiri (1.16.0-arm64-darwin)
       racc (~> 1.4)
-    nokogiri (1.16.2-x86_64-darwin)
+    nokogiri (1.16.0-x86_64-darwin)
       racc (~> 1.4)
-    nokogiri (1.16.2-x86_64-linux)
+    nokogiri (1.16.0-x86_64-linux)
       racc (~> 1.4)
     oauth2 (2.0.9)
       faraday (>= 0.17.3, < 3.0)
@@ -406,8 +405,7 @@ GEM
       rack (>= 1.2, < 4)
       snaky_hash (~> 2.0)
       version_gem (~> 1.1)
-    octokit (8.1.0)
-      base64
+    octokit (8.0.0)
       faraday (>= 1, < 3)
       sawyer (~> 0.9)
     omniauth (2.1.2)
@@ -425,7 +423,10 @@ GEM
       time
       uri
     orm_adapter (0.5.0)
-    parser (3.3.0.5)
+    orthotypo (1.0.0)
+      htmlentities
+      nokogiri
+    parser (3.2.2.4)
       ast (~> 2.4.1)
       racc
     pexels (0.5.0)
@@ -435,36 +436,35 @@ GEM
     psych (5.1.2)
       stringio
     public_suffix (5.0.4)
-    puma (6.4.2)
+    puma (6.4.0)
       nio4r (~> 2.0)
     racc (1.7.3)
-    rack (3.0.9)
+    rack (2.2.8)
     rack-mini-profiler (2.3.4)
       rack (>= 1.2.0)
-    rack-protection (4.0.0)
-      base64 (>= 0.1.0)
-      rack (>= 3.0.0, < 4)
-    rack-session (2.0.0)
-      rack (>= 3.0.0)
+    rack-protection (3.1.0)
+      rack (~> 2.2, >= 2.2.4)
+    rack-session (1.0.2)
+      rack (< 3)
     rack-test (2.1.0)
       rack (>= 1.3)
-    rackup (2.1.0)
-      rack (>= 3)
-      webrick (~> 1.8)
-    rails (7.1.3)
-      actioncable (= 7.1.3)
-      actionmailbox (= 7.1.3)
-      actionmailer (= 7.1.3)
-      actionpack (= 7.1.3)
-      actiontext (= 7.1.3)
-      actionview (= 7.1.3)
-      activejob (= 7.1.3)
-      activemodel (= 7.1.3)
-      activerecord (= 7.1.3)
-      activestorage (= 7.1.3)
-      activesupport (= 7.1.3)
+    rackup (1.0.0)
+      rack (< 3)
+      webrick
+    rails (7.1.2)
+      actioncable (= 7.1.2)
+      actionmailbox (= 7.1.2)
+      actionmailer (= 7.1.2)
+      actionpack (= 7.1.2)
+      actiontext (= 7.1.2)
+      actionview (= 7.1.2)
+      activejob (= 7.1.2)
+      activemodel (= 7.1.2)
+      activerecord (= 7.1.2)
+      activestorage (= 7.1.2)
+      activesupport (= 7.1.2)
       bundler (>= 1.15.0)
-      railties (= 7.1.3)
+      railties (= 7.1.2)
     rails-autocomplete (2.0.1)
       rails (>= 4.0)
     rails-dom-testing (2.2.0)
@@ -477,9 +477,9 @@ GEM
     rails-i18n (7.0.8)
       i18n (>= 0.7, < 2)
       railties (>= 6.0.0, < 8)
-    railties (7.1.3)
-      actionpack (= 7.1.3)
-      activesupport (= 7.1.3)
+    railties (7.1.2)
+      actionpack (= 7.1.2)
+      activesupport (= 7.1.2)
       irb
       rackup (>= 1.0.0)
       rake (>= 12.2)
@@ -492,8 +492,8 @@ GEM
       ffi (~> 1.0)
     rdoc (6.6.2)
       psych (>= 4.0.0)
-    regexp_parser (2.9.0)
-    reline (0.4.2)
+    regexp_parser (2.8.3)
+    reline (0.4.1)
       io-console (~> 0.5)
     requests (1.0.2)
     require_all (3.0.0)
@@ -501,7 +501,7 @@ GEM
       actionpack (>= 5.2)
       railties (>= 5.2)
     rexml (3.2.6)
-    roo (2.10.1)
+    roo (2.10.0)
       nokogiri (~> 1)
       rubyzip (>= 1.3.0, < 3.0.0)
     rotp (6.3.0)
@@ -554,11 +554,10 @@ GEM
       simplecov_json_formatter (~> 0.1)
     simplecov-html (0.12.3)
     simplecov_json_formatter (0.1.4)
-    sinatra (4.0.0)
+    sinatra (3.1.0)
       mustermann (~> 3.0)
-      rack (>= 3.0.0, < 4)
-      rack-protection (= 4.0.0)
-      rack-session (>= 2.0.0, < 3)
+      rack (~> 2.2, >= 2.2.4)
+      rack-protection (= 3.1.0)
       tilt (~> 2.0)
     snaky_hash (2.0.1)
       hashie
@@ -587,7 +586,7 @@ GEM
       ethon (>= 0.9.0)
     tzinfo (2.0.6)
       concurrent-ruby (~> 1.0)
-    tzinfo-data (1.2024.1)
+    tzinfo-data (1.2023.4)
       tzinfo (>= 1.0.0)
     unaccent (0.4.0)
     unicode-display_width (2.5.0)
@@ -620,13 +619,12 @@ GEM
     websocket-extensions (0.1.5)
     xpath (3.2.0)
       nokogiri (~> 1.8)
-    zeitwerk (2.6.13)
+    zeitwerk (2.6.12)
     zlib (2.1.1)
 
 PLATFORMS
   arm64-darwin-21
   arm64-darwin-22
-  arm64-darwin-23
   x86_64-darwin-21
   x86_64-darwin-22
   x86_64-darwin-23
@@ -686,6 +684,7 @@ DEPENDENCIES
   octokit
   omniauth-rails_csrf_protection (~> 1)
   omniauth-saml (~> 2)
+  orthotypo
   pexels (~> 0)
   pg (~> 1)
   puma
@@ -719,4 +718,4 @@ RUBY VERSION
    ruby 3.3.0p0
 
 BUNDLED WITH
-   2.5.3
+   2.3.26
diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb
index 036dfebf5..d9c051ab5 100644
--- a/app/helpers/admin/application_helper.rb
+++ b/app/helpers/admin/application_helper.rb
@@ -129,25 +129,17 @@ module Admin::ApplicationHelper
                 form: form.options.dig(:html, :id)
   end
 
-  def prepare_html_for_static(html, university)
-    text = html.to_s.strip.dup
-    text = sanitize text
-    text.gsub! "\r", ''
-    text.gsub! "\n", ' '
-    text.gsub! "/rails/active_storage", "#{university.url}/rails/active_storage"
-    sanitize text
+  def prepare_html_for_static(text)
+    university = current_university || @website&.university || @about&.university
+    Static::Html.new(text, about: @about, university: university).prepared
   end
 
-  def prepare_text_for_static(text, depth = 1)
-    text = strip_tags text.to_s.strip.dup
-    text = indent text, depth
-    CGI.unescapeHTML text
+  def prepare_text_for_static(text, depth: 1)
+    Static::Text.new(text, depth: depth, about: @about).prepared
   end
 
-  def prepare_code_for_static(code, depth = 1)
-    text = code.to_s.dup
-    text = indent text, depth
-    raw text
+  def prepare_code_for_static(text, depth: 1)
+    Static::Code.new(text, depth: depth, about: @about).prepared
   end
 
   def has_content?(html)
diff --git a/app/services/static/code.rb b/app/services/static/code.rb
new file mode 100644
index 000000000..ec9935806
--- /dev/null
+++ b/app/services/static/code.rb
@@ -0,0 +1,12 @@
+class Static::Code < Static::Default
+
+  def prepared
+    unless @prepared
+      @prepared = @text.to_s.dup
+      @prepared = indent @prepared
+      @prepared = raw @prepared
+    end
+    @prepared
+  end
+
+end
\ No newline at end of file
diff --git a/app/services/static/default.rb b/app/services/static/default.rb
new file mode 100644
index 000000000..a61760912
--- /dev/null
+++ b/app/services/static/default.rb
@@ -0,0 +1,35 @@
+class Static::Default
+  include ActionView::Helpers
+
+  def initialize(text, depth: 1, about: nil, university: nil)
+    @text = text
+    @depth = depth
+    @about = about
+    @university = university
+  end
+
+  def prepared
+    raise NotImplementedError
+  end
+
+  protected
+
+  def locale
+    return if @about.nil?
+    return unless @about.respond_to?(:language)
+    @about.language&.iso_code
+  end
+
+  def indent(text)
+    indentation = '  ' * @depth
+    # Remove useless \r
+    text.gsub! "\r\n", "\n"
+    # Replace lonely \r
+    text.gsub! "\r", "\n"
+    # Indent properly to avoid broken frontmatter, with 2 lines so the linebreak work
+    text.gsub! "\n", "\n#{indentation}\n#{indentation}"
+    text.chomp!
+    text
+  end
+
+end
diff --git a/app/services/static/html.rb b/app/services/static/html.rb
new file mode 100644
index 000000000..40d2c4adf
--- /dev/null
+++ b/app/services/static/html.rb
@@ -0,0 +1,16 @@
+class Static::Html < Static::Default
+
+  def prepared
+    unless @prepared
+      @prepared = @text.to_s.strip.dup
+      @prepared = @prepared.ortho(locale: locale)
+      @prepared = sanitize @prepared
+      @prepared.gsub! "\r", ''
+      @prepared.gsub! "\n", ' '
+      @prepared.gsub! "/rails/active_storage", "#{@university.url}/rails/active_storage"      
+      @prepared = sanitize @prepared
+    end
+    @prepared
+  end
+
+end
\ No newline at end of file
diff --git a/app/services/static/text.rb b/app/services/static/text.rb
new file mode 100644
index 000000000..a91e4c839
--- /dev/null
+++ b/app/services/static/text.rb
@@ -0,0 +1,14 @@
+class Static::Text < Static::Default
+
+  def prepared
+    unless @prepared
+      @prepared = @text.to_s.strip.dup
+      @prepared = strip_tags @prepared
+      @prepared = CGI.unescapeHTML @prepared
+      @prepared = @prepared.ortho(locale: locale)
+      @prepared = indent @prepared
+    end
+    @prepared
+  end
+
+end
\ No newline at end of file
diff --git a/app/views/admin/application/featured_image/_static.html.erb b/app/views/admin/application/featured_image/_static.html.erb
index 12e6953f1..ab932b45d 100644
--- a/app/views/admin/application/featured_image/_static.html.erb
+++ b/app/views/admin/application/featured_image/_static.html.erb
@@ -5,6 +5,6 @@ if best_featured_image&.attached?
 image:
   id: "<%= best_featured_image.blob.id %>"
   alt: "<%= @about.best_featured_image_alt %>"
-  credit: >
-    <%= prepare_html_for_static @about.best_featured_image_credit, @about.university %>
+  credit: >-
+    <%= prepare_html_for_static @about.best_featured_image_credit %>
 <% end %>
diff --git a/app/views/admin/application/summary/_static.html.erb b/app/views/admin/application/summary/_static.html.erb
index a90e39b22..50fc43d38 100644
--- a/app/views/admin/application/summary/_static.html.erb
+++ b/app/views/admin/application/summary/_static.html.erb
@@ -1,5 +1,2 @@
 summary: >
   <%= prepare_text_for_static @about.summary %>
-<%# TODO: legacy: remove when theme doesn't use description_short anymore %>
-description_short: >
-  <%= prepare_text_for_static @about.summary %>
diff --git a/app/views/admin/communication/blocks/components/code/_static.html.erb b/app/views/admin/communication/blocks/components/code/_static.html.erb
index 2d3119af2..b9a018604 100644
--- a/app/views/admin/communication/blocks/components/code/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/code/_static.html.erb
@@ -1,7 +1,7 @@
 <% if list %>
 <%= indentation %>- <%= property %>: >-
-<%= indentation %>    <%= prepare_code_for_static value, depth + 2 %>
+<%= indentation %>    <%= prepare_code_for_static value, depth: depth + 2 %>
 <% else %>
 <%= indentation %><%= property %>: >-
-<%= indentation %>  <%= prepare_code_for_static value, depth + 1 %>
+<%= indentation %>  <%= prepare_code_for_static value, depth: depth + 1 %>
 <% end %>
diff --git a/app/views/admin/communication/blocks/components/rich_text/_static.html.erb b/app/views/admin/communication/blocks/components/rich_text/_static.html.erb
index c4afc9949..0925b7b69 100644
--- a/app/views/admin/communication/blocks/components/rich_text/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/rich_text/_static.html.erb
@@ -1,7 +1,7 @@
 <% if list %>
 <%= indentation %>- <%= property %>: >-
-<%= indentation %>    <%= prepare_html_for_static value, @university, depth + 2 %>
+<%= indentation %>    <%= prepare_html_for_static value %>
 <% else %>
 <%= indentation %><%= property %>: >-
-<%= indentation %>  <%= prepare_html_for_static value, @university %>
+<%= indentation %>  <%= prepare_html_for_static value %>
 <% end %>
diff --git a/app/views/admin/communication/blocks/components/string/_static.html.erb b/app/views/admin/communication/blocks/components/string/_static.html.erb
index f6f87c8bd..c143f75b6 100644
--- a/app/views/admin/communication/blocks/components/string/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/string/_static.html.erb
@@ -1,7 +1,7 @@
 <% if list %>
 <%= indentation %>- <%= property %>: >-
-<%= indentation %>    <%= prepare_text_for_static value, depth + 2 %>
+<%= indentation %>    <%= prepare_text_for_static value, depth: depth + 2 %>
 <% else %>
 <%= indentation %><%= property %>: >-
-<%= indentation %>  <%= prepare_text_for_static value, depth + 1 %>
+<%= indentation %>  <%= prepare_text_for_static value, depth: depth + 1 %>
 <% end %>
diff --git a/app/views/admin/communication/blocks/components/text/_static.html.erb b/app/views/admin/communication/blocks/components/text/_static.html.erb
index f6f87c8bd..c143f75b6 100644
--- a/app/views/admin/communication/blocks/components/text/_static.html.erb
+++ b/app/views/admin/communication/blocks/components/text/_static.html.erb
@@ -1,7 +1,7 @@
 <% if list %>
 <%= indentation %>- <%= property %>: >-
-<%= indentation %>    <%= prepare_text_for_static value, depth + 2 %>
+<%= indentation %>    <%= prepare_text_for_static value, depth: depth + 2 %>
 <% else %>
 <%= indentation %><%= property %>: >-
-<%= indentation %>  <%= prepare_text_for_static value, depth + 1 %>
+<%= indentation %>  <%= prepare_text_for_static value, depth: depth + 1 %>
 <% end %>
diff --git a/app/views/admin/communication/blocks/headings/_static.html.erb b/app/views/admin/communication/blocks/headings/_static.html.erb
index 316919c0f..65dd67fc1 100644
--- a/app/views/admin/communication/blocks/headings/_static.html.erb
+++ b/app/views/admin/communication/blocks/headings/_static.html.erb
@@ -1,6 +1,5 @@
   - kind: heading
-    title: >-
-      <%= prepare_text_for_static heading.title %>
+    title: "<%= prepare_text_for_static heading.title %>"
     position: <%= heading.position %>
     rank: <%= heading.level %>
 <% heading.blocks.published.ordered.each do |block| %>
diff --git a/app/views/admin/communication/websites/agenda/events/static.html.erb b/app/views/admin/communication/websites/agenda/events/static.html.erb
index 1e44c20d8..a028d7d80 100644
--- a/app/views/admin/communication/websites/agenda/events/static.html.erb
+++ b/app/views/admin/communication/websites/agenda/events/static.html.erb
@@ -1,6 +1,6 @@
 ---
-title: "<%= @about.title %>"
-subtitle: "<%= @about.subtitle %>"
+title: "<%= prepare_text_for_static @about.title %>"
+subtitle: "<%= prepare_text_for_static @about.subtitle %>"
 <%= render 'admin/communication/websites/agenda/events/dates_static', event: @about %>
 <%= render 'admin/application/static/breadcrumbs',
             pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self,
diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb
index d9b323540..c4289097d 100644
--- a/app/views/admin/communication/websites/pages/static.html.erb
+++ b/app/views/admin/communication/websites/pages/static.html.erb
@@ -1,7 +1,7 @@
 ---
-title: "<%= @about.title %>"
-breadcrumb_title: "<%= @about.best_title  %>"
-<%= render 'admin/application/static/breadcrumbs',
+title: "<%= prepare_text_for_static @about.title %>"
+breadcrumb_title: "<%= prepare_text_for_static @about.best_title %>"
+<%= render 'admin/application/static/breadcrumbs', 
             pages: @about.ancestors,
             current_title: @about.best_title %>
 <%= render 'admin/application/static/permalink' %>
@@ -33,10 +33,10 @@ children:
 <%= render 'admin/application/meta_description/static' %>
 <%= render 'admin/application/summary/static' %>
 header_text: >-
-  <%= prepare_html_for_static @about.header_text, @website.university %>
+  <%= prepare_html_for_static @about.header_text %>
 header_cta:
   display: <%= @about.header_cta %>
-  label: <%= @about.header_cta_label %>
+  label: <%= prepare_text_for_static @about.header_cta_label %>
   target: <%= @about.header_cta_url %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
diff --git a/app/views/admin/communication/websites/posts/categories/static.html.erb b/app/views/admin/communication/websites/posts/categories/static.html.erb
index c5bd4a51e..b9ea504db 100644
--- a/app/views/admin/communication/websites/posts/categories/static.html.erb
+++ b/app/views/admin/communication/websites/posts/categories/static.html.erb
@@ -1,5 +1,5 @@
 ---
-title: "<%= @about.name %>"
+title: "<%= prepare_text_for_static @about.name %>"
 <%= render 'admin/application/static/permalink', forced_slug: @about.slug_with_ancestors_slugs %>
 <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %>
 <%= render 'admin/application/static/breadcrumbs',
diff --git a/app/views/admin/communication/websites/posts/static.html.erb b/app/views/admin/communication/websites/posts/static.html.erb
index 8f0674964..90b219bbc 100644
--- a/app/views/admin/communication/websites/posts/static.html.erb
+++ b/app/views/admin/communication/websites/posts/static.html.erb
@@ -1,5 +1,5 @@
 ---
-title: "<%= @about.title %>"
+title: "<%= prepare_text_for_static @about.title %>"
 date: "<%= @about.published_at&.iso8601 %>"
 <%= render 'admin/application/static/breadcrumbs',
             pages: @website.special_page(Communication::Website::Page::CommunicationPost).ancestors_and_self,
@@ -25,4 +25,4 @@ posts_categories:
 <%= render 'admin/application/summary/static' %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
-<%= prepare_html_for_static @about.text, @about.university %>
+<%= prepare_html_for_static @about.text %>
diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb
index f568f2834..5cff1836c 100644
--- a/app/views/admin/education/diplomas/static.html.erb
+++ b/app/views/admin/education/diplomas/static.html.erb
@@ -1,6 +1,5 @@
 ---
-title: >
-  <%= prepare_text_for_static @about.name %>
+title: "<%= prepare_text_for_static @about.name %>"
 <%= render 'admin/application/static/permalink' if @website %>
 <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %>
 <%= render 'admin/application/static/breadcrumbs',
diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb
index aa8841780..0325e837c 100644
--- a/app/views/admin/education/programs/static.html.erb
+++ b/app/views/admin/education/programs/static.html.erb
@@ -7,8 +7,7 @@ administrator_involvements = @about.involvements_through_roles
                                    .includes(:person)
                                    .ordered_by_name
 %>
-title: >
-  <%= @about.name %>
+title: "<%= prepare_text_for_static @about.name %>"
 <%= render 'admin/application/static/permalink' %>
 <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: true, toc_present: true %>
 <%= render 'admin/application/static/breadcrumbs',
@@ -87,7 +86,7 @@ apprenticeship: <%= @about.apprenticeship %>
   :results
 ].each do |property| %>
 <%= property.to_s %>: >
-  <%= prepare_html_for_static @about.send("best_#{property}"), @about.university %>
+  <%= prepare_html_for_static @about.send("best_#{property}") %>
 <% end %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
diff --git a/app/views/admin/education/schools/static.html.erb b/app/views/admin/education/schools/static.html.erb
index 01bafc821..b2d44ac49 100644
--- a/app/views/admin/education/schools/static.html.erb
+++ b/app/views/admin/education/schools/static.html.erb
@@ -1,17 +1,12 @@
 ---
 <% administrator_involvements = @about.involvements_through_roles.includes(:person).ordered_by_name %>
-name: >
-  <%= @about.name %>
-address: >
-  <%= @about.address %>
-zipcode: >
-  <%= @about.zipcode %>
-city: >
-  <%= @about.city %>
-country: >
-  <%= @about.country_common_name %>
-phone: >
-  <%= @about.phone %>
+name: "<%= prepare_text_for_static @about.name %>"
+address: >-
+  <%= prepare_text_for_static @about.address %>
+zipcode: "<%= prepare_text_for_static @about.zipcode %>"
+city: "<%= prepare_text_for_static @about.city %>"
+country: "<%= prepare_text_for_static @about.country_common_name %>"
+phone: "<%= prepare_text_for_static @about.phone %>"
 <% if administrator_involvements.any? %>
 administrators:
 <% administrator_involvements.each do |involvement| %>
@@ -25,7 +20,7 @@ administrators_description:
 roles:
 <% @about.university_roles.ordered.each do |role| %>
   - title: >
-      <%= role.to_s %>
+      <%= prepare_text_for_static role.to_s %>
     persons:
     <% role.involvements.includes(:person).ordered.each do |involvement| %>
       - "<%= involvement.person.slug %>"
diff --git a/app/views/admin/research/journals/papers/kinds/static.html.erb b/app/views/admin/research/journals/papers/kinds/static.html.erb
index 2e4291d1f..bc90c128b 100644
--- a/app/views/admin/research/journals/papers/kinds/static.html.erb
+++ b/app/views/admin/research/journals/papers/kinds/static.html.erb
@@ -1,5 +1,4 @@
 ---
-title: >-
-  <%= prepare_text_for_static @about.title %>
+title: "<%= prepare_text_for_static @about.title %>"
 slug: "<%= @about.slug %>"
 ---
diff --git a/app/views/admin/research/journals/papers/static.html.erb b/app/views/admin/research/journals/papers/static.html.erb
index bd77d6822..a18d8dec6 100644
--- a/app/views/admin/research/journals/papers/static.html.erb
+++ b/app/views/admin/research/journals/papers/static.html.erb
@@ -1,14 +1,13 @@
 ---
-title: >-
-  <%= prepare_text_for_static @about.title %>
+title: "<%= prepare_text_for_static @about.title %>"
+<%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false, toc_present: true %>
 <%= render 'admin/application/static/permalink' %>
 <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %>
 <%= render 'admin/application/static/breadcrumbs',
             pages: @website.special_page(Communication::Website::Page::ResearchPaper).ancestors_and_self,
             current_title: @about.to_s %>
 <% if @about.kind %>
-paper_kind: >-
-  <%= prepare_text_for_static @about.kind %>
+paper_kind: "<%= prepare_text_for_static @about.kind %>"
 paper_kinds:
   - "<%= @about.kind.slug %>"
 <% end %>
@@ -27,7 +26,7 @@ pdf: "<%= @about.pdf.blob_id %>"
 <% end %>
 <% if @about.bibliography %>
 bibliography: >
-  <%= prepare_html_for_static @about.bibliography, @about.university %>
+  <%= prepare_html_for_static @about.bibliography %>
 <% end %>
 keywords: >
   <%= prepare_text_for_static @about.keywords %>
@@ -35,8 +34,7 @@ researchers:
 <% @about.people.each do |person| %>
 - "<%= person.slug %>"
 <% end %>
-authors_list: >
-  <%= prepare_text_for_static @about.authors_list %>
+authors_list: "<%= prepare_text_for_static @about.authors_list %>"
 <%= render 'admin/application/meta_description/static' %>
 <%= render 'admin/application/summary/static' %>
 abstract: >
@@ -44,20 +42,20 @@ abstract: >
 citations:
   - label: "APA"
     content: >-
-      <%= prepare_html_for_static @about.citation_apa(website: @website), @website.university %>
+      <%= prepare_html_for_static @about.citation_apa(website: @website) %>
   - label: "MLA"
     content: >-
-      <%= prepare_html_for_static @about.citation_mla(website: @website), @website.university %>
+      <%= prepare_html_for_static @about.citation_mla(website: @website) %>
   - label: "Chicago"
     content: >-
-      <%= prepare_html_for_static @about.citation_chicago(website: @website), @website.university %>
+      <%= prepare_html_for_static @about.citation_chicago(website: @website) %>
   - label: "Harvard"
     content: >-
-      <%= prepare_html_for_static @about.citation_harvard(website: @website), @website.university %>
+      <%= prepare_html_for_static @about.citation_harvard(website: @website) %>
   <% if @website.default_language.iso_code == "fr" %>
   - label: "ISO 690"
     content: >-
-      <%= prepare_html_for_static @about.citation_iso690(website: @website), @website.university %>
+      <%= prepare_html_for_static @about.citation_iso690(website: @website) %>
   <% end %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
diff --git a/app/views/admin/research/journals/volumes/static.html.erb b/app/views/admin/research/journals/volumes/static.html.erb
index c47e26e1d..8a5577199 100644
--- a/app/views/admin/research/journals/volumes/static.html.erb
+++ b/app/views/admin/research/journals/volumes/static.html.erb
@@ -1,6 +1,6 @@
 ---
-title: >-
-  <%= prepare_text_for_static @about.title %>
+title: "<%= prepare_text_for_static @about.title %>"
+<%= render 'admin/application/static/design', full_width: true, toc_offcanvas: false, toc_present: false %>
 <%= render 'admin/application/static/permalink' %>
 <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: false, toc_present: false %>
 <%= render 'admin/application/static/breadcrumbs',
@@ -15,4 +15,4 @@ date: "<%= @about.published_at.iso8601 %>"
 <%= render 'admin/application/meta_description/static' %>
 <%= render 'admin/application/summary/static' %>
 ---
-<%= prepare_html_for_static @about.text, @about.university %>
+<%= prepare_html_for_static @about.text %>
diff --git a/app/views/admin/research/publications/static.html.erb b/app/views/admin/research/publications/static.html.erb
index e3e5a1d2b..d23788e39 100644
--- a/app/views/admin/research/publications/static.html.erb
+++ b/app/views/admin/research/publications/static.html.erb
@@ -14,9 +14,9 @@ hal:
   docid: "<%= @about.hal_docid %>"
   url: "<%= @about.hal_url %>"
 abstract: >-
-  <%= prepare_html_for_static @about.abstract, @website.university %>
+  <%= prepare_html_for_static @about.abstract %>
 citation_full: >-
-  <%= prepare_html_for_static @about.citation_full, @website.university %>
+  <%= prepare_html_for_static @about.citation_full %>
 authors_list: >-
   <%= @about.authors_list %>
 ref: >-
@@ -43,6 +43,6 @@ Citations::FORMATS.each do |format|
   - label: "<%= t("research.citations.#{format}.label") %>"
     format: "<%= format %>"
     content: >-
-      <%= prepare_html_for_static citation, @website.university %>
+      <%= prepare_html_for_static citation %>
 <% end %>
 ---
\ No newline at end of file
diff --git a/app/views/admin/university/organizations/static.html.erb b/app/views/admin/university/organizations/static.html.erb
index fc5c5f245..840f826cf 100644
--- a/app/views/admin/university/organizations/static.html.erb
+++ b/app/views/admin/university/organizations/static.html.erb
@@ -1,7 +1,6 @@
 ---
-title: >
-  <%= @about.to_s %>
-<%= render 'admin/application/static/breadcrumbs',
+title: "<%= prepare_text_for_static @about.to_s %>"
+<%= render 'admin/application/static/breadcrumbs', 
             pages: @website.special_page(Communication::Website::Page::Organization).ancestors_and_self,
             current_title: @about.to_s %>
 <%= render 'admin/application/static/permalink' %>
@@ -59,4 +58,4 @@ logo_on_dark_background: "<%= @about.logo_on_dark_background.blob.id %>"
 <%= render 'admin/application/connections/backlinks' %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
-<%= prepare_html_for_static @about.text, @about.university %>
+<%= prepare_html_for_static @about.text %>
diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb
index 74085ceb6..4ed217550 100644
--- a/app/views/admin/university/people/static.html.erb
+++ b/app/views/admin/university/people/static.html.erb
@@ -41,7 +41,7 @@ contact_details:
 <% if @about.best_picture.attached? %>
 image: "<%= @about.best_picture.blob.id %>"
 credit: >-
-  <%= prepare_html_for_static @about.picture_credit, @about.university %>
+  <%= prepare_html_for_static @about.picture_credit %>
 <% end %>
 roles:
 <% if @about.author.for_website?(@website) %>
@@ -86,4 +86,4 @@ administrative_missions:
 <%= render 'admin/application/connections/backlinks' %>
 <%= render 'admin/communication/blocks/content/static', about: @about %>
 ---
-<%= prepare_html_for_static @about.biography, @about.university %>
+<%= prepare_html_for_static @about.biography %>
diff --git a/db/schema.rb b/db/schema.rb
index 123d12852..b762c688f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -140,8 +140,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_12_105952) do
     t.datetime "updated_at", null: false
     t.string "title"
     t.boolean "published", default: true
-    t.uuid "heading_id"
     t.uuid "communication_website_id"
+    t.uuid "heading_id"
     t.string "migration_identifier"
     t.index ["about_type", "about_id"], name: "index_communication_website_blocks_on_about"
     t.index ["communication_website_id"], name: "index_communication_blocks_on_communication_website_id"
@@ -457,7 +457,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_12_105952) do
     t.index ["university_id"], name: "index_communication_website_pages_on_university_id"
   end
 
-  create_table "communication_website_permalinks", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
+  create_table "communication_website_permalinks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "website_id", null: false
     t.string "about_type", null: false
-- 
GitLab