diff --git a/app/javascript/gabsocial/components/panel/group_info_panel.js b/app/javascript/gabsocial/components/panel/group_info_panel.js
index 310c124f..312c299c 100644
--- a/app/javascript/gabsocial/components/panel/group_info_panel.js
+++ b/app/javascript/gabsocial/components/panel/group_info_panel.js
@@ -39,6 +39,7 @@ class GroupInfoPanel extends ImmutablePureComponent {
const isPrivate = !!group ? group.get('is_private') : false
const isVisible = !!group ? group.get('is_visible') : false
const tags = !!group ? group.get('tags') : []
+ const descriptionHTML = !!group ? { __html: group.get('description_html') } : {}
if (noPanel) {
return (
@@ -56,7 +57,7 @@ class GroupInfoPanel extends ImmutablePureComponent {
}
- {group.get('description')}
+
@@ -89,7 +90,7 @@ class GroupInfoPanel extends ImmutablePureComponent {
- {group.get('description')}
+
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index bdd802e2..855e51bf 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -125,6 +125,19 @@ class Formatter
html
end
+ def formatGroupDescription(raw_content)
+ return '' if raw_content.blank?
+
+ html = raw_content
+ html = format_markdown(html)
+ html = encode_and_link_urls(html, nil, keep_html: true)
+ html = html.gsub(/(?:\n\r?|\r\n?)/, '
')
+ html = html.delete("\n")
+ html.html_safe # rubocop:disable Rails/OutputSafety
+
+ html
+ end
+
def format_markdown(html)
html = markdown_formatter.render(html)
html = html.gsub(/\n/, '
')
diff --git a/app/serializers/rest/group_serializer.rb b/app/serializers/rest/group_serializer.rb
index a0554874..0a637bed 100644
--- a/app/serializers/rest/group_serializer.rb
+++ b/app/serializers/rest/group_serializer.rb
@@ -3,7 +3,7 @@
class REST::GroupSerializer < ActiveModel::Serializer
include RoutingHelper
- attributes :id, :title, :description, :cover_image_url, :is_archived,
+ attributes :id, :title, :description, :description_html, :cover_image_url, :is_archived,
:member_count, :created_at, :is_private, :is_visible, :slug, :tags, :category
def id
@@ -14,6 +14,14 @@ class REST::GroupSerializer < ActiveModel::Serializer
object.group_categories_id
end
+ def description
+ object.description
+ end
+
+ def description_html
+ Formatter.instance.formatGroupDescription(object.description).strip
+ end
+
def clean_migrated_url
object
.cover_image_file_name