Merge pull request #5136 from Meet-Democracy/Legislation-draft-render-markdown-tables

Render markdown tables in legislation draft
This commit is contained in:
Javi Martín
2023-06-30 00:09:33 +02:00
committed by GitHub
9 changed files with 240 additions and 27 deletions

View File

@@ -459,6 +459,10 @@
padding: rem-calc(32) rem-calc(32) rem-calc(32) rem-calc(48);
}
table {
@include table-scroll;
}
h2 {
font-weight: 400;
margin-bottom: rem-calc(32);

View File

@@ -10,26 +10,8 @@ module ApplicationHelper
%i[ar fa he].include?(locale)
end
def markdown(text)
return text if text.blank?
# See https://github.com/vmg/redcarpet for options
render_options = {
filter_html: false,
hard_wrap: true,
link_attributes: { target: "_blank" }
}
renderer = Redcarpet::Render::HTML.new(render_options)
extensions = {
autolink: true,
fenced_code_blocks: true,
lax_spacing: true,
no_intra_emphasis: true,
strikethrough: true,
superscript: true
}
AdminLegislationSanitizer.new.sanitize(Redcarpet::Markdown.new(renderer, extensions).render(text))
def markdown(text, **render_options)
MarkdownConverter.new(text, **render_options).render
end
def wysiwyg(text)

View File

@@ -22,15 +22,11 @@ class Legislation::DraftVersion < ApplicationRecord
scope :published, -> { where(status: "published").order("id DESC") }
def body_html
renderer = Redcarpet::Render::HTML.new(with_toc_data: true)
Redcarpet::Markdown.new(renderer).render(body)
MarkdownConverter.new(body, with_toc_data: true).render
end
def toc_html
renderer = Redcarpet::Render::HTML_TOC.new(with_toc_data: true)
Redcarpet::Markdown.new(renderer).render(body)
MarkdownConverter.new(body).render_toc
end
def display_title