##前提条件
gem 'redcarpet'を使用して個人アプリにマークダウン形式を導入しようとしています。
コードを書き込むことはできるようになったのですがなぜかh1タグ、h2タグがページに反映されていません。
検証ツールを使って要素を見ているのですが
表示ではh1,h2,h3となっているので余計にわかりません。
cssが邪魔しているの?と思いfont-sizeなどは指定せずにいるのですがそれでもうまくいきません。
! from Gyazo](https://gyazo.com/f01727cb6f960579c601115cb6c737c3)
実現したいことはマークダウンで入力した通りの表示ができるようにしたいです。
##該当コード
application_helper.rb
Ruby:application_hepler.rb![イメージ説明](084f6acb5d38793f7de1259d8079398e.png)
1module ApplicationHelper 2 require "redcarpet" 3 require "coderay" 4 5 class HTMLwithCoderay < Redcarpet::Render::HTML 6 def block_code(code, language) 7 language = language.split(':')[0] 8 9 case language.to_s 10 when 'rb' 11 lang = 'ruby' 12 when 'yml' 13 lang = 'yaml' 14 when 'css' 15 lang = 'css' 16 when 'html' 17 lang = 'html' 18 when '' 19 lang = 'md' 20 else 21 lang = language 22 end 23 24 CodeRay.scan(code, lang).div 25 end 26 end 27 28 def markdown(text) 29 html_render = HTMLwithCoderay.new(filter_html: true, hard_wrap: true) 30 options = { 31 autolink: true, 32 space_after_headers: true, 33 no_intra_emphasis: true, 34 fenced_code_blocks: true, 35 tables: true, 36 hard_wrap: true, 37 xhtml: true, 38 lax_html_blocks: true, 39 strikethrough: true 40 } 41 markdown = Redcarpet::Markdown.new(html_render, options) 42 markdown.render(text) 43 end 44end
使用しているgem 'redcarpet'のhelperの記述です。
ruby
1show.html.haml 2 3 .show_content 4 = markdown(@post.content).html_safe 5 6 7 -if current_user.id = @post.user_id 8 .show_form 9 .show_form__edit 10 =link_to 'EDIT',edit_post_path(@post.id) 11 .show_form__delete 12 =link_to 'DELETE',post_path(@post.id) ,method: :delete
回答1件
あなたの回答
tips
プレビュー