Skip to content

Commit 2c9de49

Browse files
committedJul 19, 2024
render summary as markdown
1 parent f4f9429 commit 2c9de49

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed
 

‎Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,5 @@ gem "active_job-performs", "~> 0.3.1"
124124
gem "ruby-openai"
125125

126126
gem "json-repair", "~> 0.2.0"
127+
128+
gem "redcarpet", "~> 3.6"

‎Gemfile.lock

+2
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ GEM
350350
logger
351351
rdoc (6.7.0)
352352
psych (>= 4.0.0)
353+
redcarpet (3.6.0)
353354
regexp_parser (2.9.2)
354355
reline (0.5.9)
355356
io-console (~> 0.5)
@@ -514,6 +515,7 @@ DEPENDENCIES
514515
rails (~> 7.2.0.beta2)
515516
rails-controller-testing
516517
rails_autolink (~> 1.1)
518+
redcarpet (~> 3.6)
517519
ruby-lsp-rails
518520
ruby-openai
519521
selenium-webdriver

‎app/assets/stylesheets/application.css

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import "tailwindcss/utilities";
44

55
@import "components/form.css";
6+
@import "components/markdown.css";
67
@import "components/nav.css";
78
@import "components/pagination.css";
89
@import "components/transition.css";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@layer components {
2+
.markdown {
3+
p {
4+
@apply mb-4;
5+
}
6+
7+
h1,
8+
h2,
9+
h3,
10+
h4,
11+
h5,
12+
h6 {
13+
@apply mb-4;
14+
}
15+
16+
ul {
17+
@apply mb-4;
18+
}
19+
20+
ol {
21+
@apply mb-4;
22+
}
23+
}
24+
}

‎app/helpers/markdown_helper.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module MarkdownHelper
2+
def markdown_to_html(markdown_content)
3+
renderer = Redcarpet::Render::HTML.new(hard_wrap: true)
4+
markdown = Redcarpet::Markdown.new(renderer)
5+
markdown.render(markdown_content).html_safe
6+
end
7+
end

‎app/views/talks/_talk.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
by <%= talk.speakers.map(&:name).to_sentence %>
3131
</div>
3232

33-
<div><%= simple_format talk.summary, class: "mb-4" %></div>
33+
<div class="markdown"><%= markdown_to_html(talk.summary) %></div>
3434
</div>
3535
<% end %>
3636

0 commit comments

Comments
 (0)
Please sign in to comment.