about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-11 14:29:21 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-11 14:29:21 -0400
commitce2e4c010c68527f10e0c7b3df59f1c2f22ddc6f (patch)
treeb3754a2134ccdcf649409b7ff183a7beedabcab1 /app
parent6e70f376d23c21a63ff4875a1f77e19f7961b7b4 (diff)
downloadthoughts-ce2e4c010c68527f10e0c7b3df59f1c2f22ddc6f.tar.gz
thoughts-ce2e4c010c68527f10e0c7b3df59f1c2f22ddc6f.tar.bz2
thoughts-ce2e4c010c68527f10e0c7b3df59f1c2f22ddc6f.zip
Syntax highlighting
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/main/rouge.css.erb11
-rw-r--r--app/helpers/application_helper.rb12
2 files changed, 21 insertions, 2 deletions
diff --git a/app/assets/stylesheets/main/rouge.css.erb b/app/assets/stylesheets/main/rouge.css.erb new file mode 100644 index 0000000..120dc02 --- /dev/null +++ b/app/assets/stylesheets/main/rouge.css.erb
@@ -0,0 +1,11 @@
1<%= Rouge::Themes::Pastie.render(:scope => '.highlight') %>
2
3.highlight {
4 background-color: white;
5 padding: 1em;
6}
7
8.highlight .err {
9 color: #a61717;
10 background-color: #f5f7f9;
11}
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f12cdd4..861dd11 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb
@@ -1,5 +1,13 @@
1require 'redcarpet'
2require 'rouge'
3require 'rouge/plugins/redcarpet'
4
1module ApplicationHelper 5module ApplicationHelper
2 6
7 class HTML < Redcarpet::Render::HTML
8 include Rouge::Plugins::Redcarpet # yep, that's it.
9 end
10
3 def title(text) 11 def title(text)
4 content_for :title, text 12 content_for :title, text
5 end 13 end
@@ -12,8 +20,8 @@ module ApplicationHelper
12 end 20 end
13 21
14 def markdown(text) 22 def markdown(text)
15 options = %i[] 23 options = { fenced_code_blocks: true, highlight: true }
16 Markdown.new(text, *options).to_html.html_safe 24 Redcarpet::Markdown.new(HTML.new(), options).render(text).html_safe
17 end 25 end
18 26
19end 27end