aboutsummaryrefslogtreecommitdiffstats
path: root/guides/rails_guides/markdown.rb
diff options
context:
space:
mode:
Diffstat (limited to 'guides/rails_guides/markdown.rb')
-rw-r--r--guides/rails_guides/markdown.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/guides/rails_guides/markdown.rb b/guides/rails_guides/markdown.rb
index a98aa8fe66..018f49ffd0 100644
--- a/guides/rails_guides/markdown.rb
+++ b/guides/rails_guides/markdown.rb
@@ -3,6 +3,7 @@
require "redcarpet"
require "nokogiri"
require "rails_guides/markdown/renderer"
+require "rails-html-sanitizer"
module RailsGuides
class Markdown
@@ -20,6 +21,7 @@ module RailsGuides
@raw_body = body
extract_raw_header_and_body
generate_header
+ generate_description
generate_title
generate_body
generate_structure
@@ -82,6 +84,11 @@ module RailsGuides
@header = engine.render(@raw_header).html_safe
end
+ def generate_description
+ sanitizer = Rails::Html::FullSanitizer.new
+ @description = sanitizer.sanitize(@header).squish
+ end
+
def generate_structure
@headings_for_index = []
if @body.present?
@@ -165,6 +172,7 @@ module RailsGuides
def render_page
@view.content_for(:header_section) { @header }
+ @view.content_for(:description) { @description }
@view.content_for(:page_title) { @title }
@view.content_for(:index_section) { @index }
@view.render(layout: @layout, html: @body.html_safe)