module GovukMarkdown
class Renderer < ::Redcarpet::Render::HTML
def initialize(govuk_options, options = {})
@headings_start_with = govuk_options[:headings_start_with]
super options
end
def table(header, body)
<<~HTML
HTML
end
def table_row(content)
<<~HTML
#{content}
HTML
end
def table_cell(content, _alignment, header)
if header
<<~HTML
HTML
else
<<~HTML
#{content}
|
HTML
end
end
def header(text, header_level)
valid_header_sizes = %w[xl l m s].freeze
start_size = valid_header_sizes.include?(@headings_start_with) ? @headings_start_with : "xl"
start_size_index = valid_header_sizes.find_index(start_size)
header_size = valid_header_sizes[start_size_index + header_level - 1] || "s"
id_attribute = @options[:with_toc_data] ? " id=\"#{text.parameterize}\"" : ""
<<~HTML
HTML
end
def paragraph(text)
<<~HTML
#{text}
HTML
end
def list(contents, list_type)
case list_type
when :unordered
<<~HTML
HTML
when :ordered
<<~HTML
#{contents}
HTML
else
raise "Unexpected type #{list_type.inspect}"
end
end
def hrule
<<~HTML
HTML
end
def preprocess(document)
Preprocessor
.new(document)
.inject_inset_text
.inject_details
.output
end
end
end