From 3a61892fcb16248b848271d82856cdc1f6207463 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Thu, 21 Apr 2022 14:04:37 +0200 Subject: [PATCH] depth --- app/helpers/admin/application_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index da3a94954..8b213f3fe 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -73,12 +73,13 @@ module Admin::ApplicationHelper sanitize text end - def prepare_text_for_static(text) - indentation = ' ' # Beware, it works only at level one, with 2 spaces + def prepare_text_for_static(text, depth = 1) + indentation = ' ' * depth # Beware, it works only at level one, with 2 spaces text = text.to_s.dup text = strip_tags text text = text.strip text = text.gsub "\r\n", "\n" # Remove useless \r + text = text.gsub "\r", "\n" # Replace lonely \r text = text.gsub "\n", "\n#{indentation}" # Indent properly to avoid broken frontmatter text = text.chomp # Remove extra newlines CGI.unescapeHTML text -- GitLab