From ce2e4c010c68527f10e0c7b3df59f1c2f22ddc6f Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 11 Oct 2023 14:29:21 -0400 Subject: Syntax highlighting --- app/helpers/application_helper.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/helpers') 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 @@ +require 'redcarpet' +require 'rouge' +require 'rouge/plugins/redcarpet' + module ApplicationHelper + class HTML < Redcarpet::Render::HTML + include Rouge::Plugins::Redcarpet # yep, that's it. + end + def title(text) content_for :title, text end @@ -12,8 +20,8 @@ module ApplicationHelper end def markdown(text) - options = %i[] - Markdown.new(text, *options).to_html.html_safe + options = { fenced_code_blocks: true, highlight: true } + Redcarpet::Markdown.new(HTML.new(), options).render(text).html_safe end end -- cgit 1.4.1