diff options
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/main/rouge.css.erb | 11 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 12 |
4 files changed, 24 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile index 1230941..e467375 100644 --- a/Gemfile +++ b/Gemfile | |||
@@ -78,3 +78,4 @@ gem 'sprockets', '3.7.2' | |||
78 | gem 'lingo', git: "https://git.fourisland.com/lingo", glob: "rails/*.gemspec", branch: "main" | 78 | gem 'lingo', git: "https://git.fourisland.com/lingo", glob: "rails/*.gemspec", branch: "main" |
79 | gem 'will_paginate', '~> 4.0' | 79 | gem 'will_paginate', '~> 4.0' |
80 | gem 'redcarpet' | 80 | gem 'redcarpet' |
81 | gem 'rouge' | ||
diff --git a/Gemfile.lock b/Gemfile.lock index ac1e851..3ad7e17 100644 --- a/Gemfile.lock +++ b/Gemfile.lock | |||
@@ -270,6 +270,7 @@ GEM | |||
270 | actionpack (>= 5.2) | 270 | actionpack (>= 5.2) |
271 | railties (>= 5.2) | 271 | railties (>= 5.2) |
272 | rexml (3.2.6) | 272 | rexml (3.2.6) |
273 | rouge (4.1.3) | ||
273 | rubyzip (2.3.2) | 274 | rubyzip (2.3.2) |
274 | sassc (2.4.0) | 275 | sassc (2.4.0) |
275 | ffi (~> 1.9) | 276 | ffi (~> 1.9) |
@@ -364,6 +365,7 @@ DEPENDENCIES | |||
364 | pokeviewer! | 365 | pokeviewer! |
365 | rails (~> 7.0.3) | 366 | rails (~> 7.0.3) |
366 | redcarpet | 367 | redcarpet |
368 | rouge | ||
367 | sassc-rails | 369 | sassc-rails |
368 | selenium-webdriver | 370 | selenium-webdriver |
369 | spring | 371 | spring |
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 @@ | |||
1 | require 'redcarpet' | ||
2 | require 'rouge' | ||
3 | require 'rouge/plugins/redcarpet' | ||
4 | |||
1 | module ApplicationHelper | 5 | module 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 | ||
19 | end | 27 | end |