Skip to content
Snippets Groups Projects
Commit 01a9de8e authored by Arnaud Levy's avatar Arnaud Levy
Browse files

fix code

parent dcc1f5fb
No related branches found
No related tags found
No related merge requests found
......@@ -77,7 +77,7 @@ module Admin::ApplicationHelper
end
def prepare_html_for_static(html, university)
text = html.to_s
text = html.to_s.dup
text = sanitize text
text.gsub! "\r", ''
text.gsub! "\n", ' '
......@@ -86,19 +86,27 @@ module Admin::ApplicationHelper
end
def prepare_text_for_static(text, depth = 1)
text = strip_tags text.to_s.dup
text = indent text, depth
CGI.unescapeHTML text
end
def prepare_code_for_static(code, depth = 1)
text = code.to_s.dup
text = indent text, depth
raw text
end
def indent(text, depth)
indentation = ' ' * depth
text = text.to_s.dup
text = strip_tags text
text = text.strip
# Remove useless \r
text = text.gsub "\r\n", "\n"
text.gsub! "\r\n", "\n"
# Replace lonely \r
text = text.gsub "\r", "\n"
text.gsub! "\r", "\n"
# Indent properly to avoid broken frontmatter, with 2 lines so the linebreak work
text = text.gsub "\n", "\n#{indentation}\n#{indentation}"
# Remove extra newlines
text = text.chomp
CGI.unescapeHTML text
text.gsub! "\n", "\n#{indentation}\n#{indentation}"
text.chomp!
text
end
def prepare_media_for_static(object, key)
......
class Communication::Block::Component::Code < Communication::Block::Component::Base
def data=(value)
@data = value
end
end
\ No newline at end of file
<% if list %>
<%= indentation %>- <%= property %>: >-
<%= indentation %> <%= prepare_html_for_static value, @university, depth + 2 %>
<%= indentation %> <%= prepare_code_for_static value, depth + 2 %>
<% else %>
<%= indentation %><%= property %>: >-
<%= indentation %> <%= prepare_html_for_static value, @university %>
<%= indentation %> <%= prepare_code_for_static value, depth + 1 %>
<% end %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment